Fix Agent Tasks Executed count broken by locale thousands separator (ADO 633444)#8472
Conversation
The Agent Test Context aggregated Agent Task IDs through a comma-separated text round-trip. The IDs were rendered with the default Format(BigInteger) which honors the current culture and inserts thousands separators on locales like en-US (e.g. 1,234,567). The downstream count and filter helpers split that text on , and treated each fragment as an ID, so for typical 6-7 digit Agent Task IDs the Agent Tasks Executed value on - AIT Test Suite, - AIT Run History (by version and by tag), - AIT Test Method Lines, - AITLogEntry API page, inflated to roughly 2-4 times the real number of distinct Agent Tasks (repro: full RT-ACCUR run with 184 tasks shows 369). The same defect made the drill-down filter built by ConvertCommaSeparatedToFilter point at unrelated Agent Tasks. Fix: serialize Agent Task IDs with Format(value, 0, 9) (XML/invariant culture) so the comma separators in the joined string are unambiguous. Resolves ADO 633444. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Could not find linked issues in the pull request description. Please make sure the pull request description contains a line that contains 'Fixes #' followed by the issue number being fixed. Use that pattern for every issue you want to link. |
Same locale Format bug unfixed for VersionNumberGetAgentTaskIDs converts VersionNumber to filter text using Format(VersionNumber) — the same locale-sensitive call that this PR fixes for Agent Task IDs. For BC version numbers ≥ 1,000 (e.g. build 24000), en-US locale renders this as "24,000", which SetFilter parses as the expression "24 OR 000", silently returning wrong results instead of filtering to the intended version. Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Same locale Format bug unfixed in GetCopilotCreditsGetCopilotCredits(…, VersionNumber: Integer, …) has the identical locale-sensitive Format(VersionNumber) call. For version numbers ≥ 1,000 the generated filter string will be malformed, causing the Copilot Credits calculation to include entries from unintended versions or return zero. Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Summary
Fix the
Agent Tasks Executedcounter (and the drill-down filter) on the AI Test Toolkit pages, which over-counts by a factor of ~2-3 on locales that render thousands separators (en-US default).Repro from ADO 633444: running the full
RT-ACCURsuite (184 distinct Agent Tasks) showsAgent Tasks Executed = 369on the AIT Test Suite page. After this fix, the counter shows184.Resolves ADO 633444.
Root cause
Codeunit 149049 "Agent Test Context Impl."aggregates the Agent Task IDs touched during a test run via a comma-separated text round-trip:GetCommaSeparatedAgentTaskIDsformats eachBigIntegerID into text and joins with", ":GetAgentTaskCountcounts elements afterSplit(','):ConvertCommaSeparatedToFilterturns the text into aSetFilterexpression by replacing,with|.The default overload
Format(BigInteger)honors the current culture. On en-US (the runtime locale for these tests, perAgentRuntimeTests'.resources), a 6-digit Agent Task ID such as1234567renders as"1,234,567"— three fragments afterSplit(',').So for
Ndistinct Agent Task IDs withcaverage internal commas, the counter returns roughlyN × (c + 1)instead ofN. With BC's current Agent Task IDs in the 6-7 digit range,c ≈ 1, giving the observed~2 × N + 1 = 369forN = 184.The drill-down filter built by
ConvertCommaSeparatedToFilter(used to navigate from the counter to the Agent Task List) was silently broken in the same way:1,234,567became the filter1|234|567, three unrelated IDs.Scope of impact (all fixed transitively by the one-line change)
Agent Tasks Executed(totals row)AgentTestSuite.PageExt.alcallsGetAgentTaskCountAgent Tasks ExecutedAgentRunHistory.PageExt.alAgent Tasks ExecutedAgentRunHistory.PageExt.alAgent Tasks Executedper lineAgentTestMethodLines.PageExt.alagentTasksExecutedConvertCommaSeparatedToFilterFix
Format(value, 0, 9)— Format type9is the XML / invariant culture format and emits the integer as a plain digit run with no group separators. This is the canonical "give me machine-parseable text for a number" pattern in BC AL and is already used elsewhere in the same submodule (e.g.LibraryAgentImpl.Codeunit.al).The change is one line plus a code comment explaining why the locale-sensitive overload must not be reintroduced here:
No other producers were found —
rg -n "Format\(.*Agent Task ID.*\)"oversrc/Tools/AI Test Toolkitreturns exactly one hit. Fixing the producer fixes all consumers.Why not change the delimiter instead?
You could also defend against this by switching from
","to a delimiter that can't appear in a culture-formatted number (e.g.";"or"|"), but that would require touching the producer and both consumers and would change a string the AIT API page surfaces. The locale-safeFormat(value, 0, 9)at the single producer is strictly smaller, strictly safer, and brings the toolkit in line with the BC convention for round-tripping numeric IDs through text.Math check
Observed: 184 distinct Agent Tasks → counter shows 369.
After fix: counter shows 184.
Pre-fix arithmetic for 6-digit IDs (
1,234,567→ 3 fragments per ID, plus the inter-ID separator):184 × 2 + 1 = 369. ✅Test notes
No new unit test is added in this change. The existing AIT regression run (
RT-ACCUR) is the repro — itsAgent Tasks Executedtotals now equal the number of distinct rows in the underlyingAgent Task Logcursor.If desired, a targeted regression test for
GetCommaSeparatedAgentTaskIDscould be added that seeds Agent Task IDs>= 1000and asserts bothGetAgentTaskCountandConvertCommaSeparatedToFilterproduce the expected values regardless ofGLOBALLANGUAGE. Happy to add this in a follow-up if maintainers want it in-tree.