You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fd0bc41
Browse filesBrowse the repository at this point in the historyBrowse files
fix(analyst): bound basis by length, state the precision range, add per-column row precision
Live sessions produced two avoidable `answer_commit` validation errors: the
"at most two sentences" check split a basis on "U.S.", and a `precision` of 14
was rejected without the bound being visible to the model. `basis` is now
bounded by `MAX_BASIS_CHARACTERS` (400) instead of a punctuation-based sentence
count, and the description and validation message state the precision range
(0 to 10). `rows` gains an optional `precision` map keyed by column name so
numeric cells, including integers, render with fixed decimals; strings, nulls
and unlisted columns are unchanged. Live sessions showed a numeric `5` rendered
where the equivalent `"5.00"` was expected.
Tests: two-sentence basis with "U.S." and "e.g." accepted; 400 characters
accepted, 401 rejected naming the bound; precision range stated in the
description and in the error for 14; row integers with precision 2 render
`5.00`, without precision `5`, numeric strings keep trailing zeros, precision
applies independently per column; the Anthropic draft-2020-12 schema test still
passes.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copy file name to clipboardExpand all lines: packages/opencode/src/altimate/tools/answer-commit.ts
+24-17Lines changed: 24 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ import { Tool } from "../../tool/tool"
5
5
6
6
/** Maximum rendered answer length, including Markdown and basis, before the model echoes it. */
7
7
exportconstMAX_RENDERED_ANSWER_CHARACTERS=60_000
8
+
exportconstMAX_BASIS_CHARACTERS=400
8
9
9
10
constrenderedLengthGuidance=`Rendered answer text must not exceed ${MAX_RENDERED_ANSWER_CHARACTERS.toLocaleString("en-US")} characters; aggregate, narrow the result, or write the full table to a file and commit the summary.`
10
11
@@ -32,15 +33,18 @@ const number = z
32
33
"Numeric values must have at most 15 significant digits and integers must be safe; pass the exact value as a string",
33
34
)
34
35
36
+
constprecisionRange="precision must be an integer from 0 to 10 (inclusive)"
"Display decimal places by column name: integer from 0 to 10 (inclusive). Numeric cells use fixed decimals, including integers; strings and nulls are unchanged. Omitted columns keep their default formatting.",
63
+
),
57
64
note: optional(z.string()).describe(
58
65
"Brief result note, including any tie at the top-N boundary; omitted when answer_only is true",
59
66
),
@@ -71,8 +78,7 @@ const rows = z
71
78
})
72
79
})
73
80
74
-
constbasisRequired=
75
-
"basis is always required: supply one or two sentences naming population, grain, source object/column, and caveats"
81
+
constbasisRequired=`basis is always required: supply one or two sentences, at most ${MAX_BASIS_CHARACTERS} characters, naming population, grain, source object/column, and caveats`
76
82
77
83
constparameters=z
78
84
.object({
@@ -100,17 +106,10 @@ const parameters = z
100
106
),
101
107
basis: z
102
108
.string({error: basisRequired})
109
+
.max(MAX_BASIS_CHARACTERS,`basis must contain at most ${MAX_BASIS_CHARACTERS} characters`)
"basis is always required: one or two sentencesnaming population, grain, the source object/column that supplies the requested entity or value, and caveats; never rendered with answer_only",
112
+
`basis is always required: one or two sentences, at most ${MAX_BASIS_CHARACTERS} characters, naming population, grain, the source object/column that supplies the requested entity or value, and caveats; never rendered with answer_only`,
114
113
),
115
114
answer_only: optional(z.boolean()),
116
115
readings: optional(
@@ -195,11 +194,19 @@ export function renderAnswer(payload: unknown): string {
`Deterministically finalize a data-question answer. Call this as the LAST tool call, once the answer is decided and all queries are finished. After it returns, reply with exactly the returned text and nothing else. Supply exactly one of fields, rows, or unresolved. Numbers are accepted up to 15 significant digits; any decimal that must be reproduced exactly (more digits, trailing zeros, or currency strings) must be passed as a string. Always supply \`basis\`; it is never shown when the request asks for only the answer. Supply one or two sentences naming population, grain, the source object/column that supplies the requested entity or value, and caveats. Resolve policy eligibility separately from metric and entity attribution: a rule about a related object does not change which object supplies the requested entity. Say in \`basis\` which source object and column supply it. When the request names N, rows.values must contain exactly N concrete rows, even with a tie at the top-N boundary; note the tie briefly in rows.note. Use answer_only when the request asks for only the answer or a specific format: the reply is exactly the value(s) or table, with no basis, field names, note, or answer label. An unresolved answer retains its unable-to-determine status. Omit unused optional properties. ${renderedLengthGuidance} This tool is not available for JSON-schema requests; use StructuredOutput instead.`,
231
+
`Deterministically finalize a data-question answer. Call this as the LAST tool call, once the answer is decided and all queries are finished. After it returns, reply with exactly the returned text and nothing else. Supply exactly one of fields, rows, or unresolved. Numbers are accepted up to 15 significant digits; any decimal that must be reproduced exactly (more digits, trailing zeros, or currency strings) must be passed as a string. For fields.precision and each rows.precision value, use an integer from 0 to 10 (inclusive). Set rows.precision by column name to display numeric cells with fixed decimal places, including integers; strings are never changed. Always supply \`basis\`; it is never shown when the request asks for only the answer. Supply one or two sentences, at most ${MAX_BASIS_CHARACTERS} characters, naming population, grain, the source object/column that supplies the requested entity or value, and caveats. Resolve policy eligibility separately from metric and entity attribution: a rule about a related object does not change which object supplies the requested entity. Say in \`basis\` which source object and column supply it. When the request names N, rows.values must contain exactly N concrete rows, even with a tie at the top-N boundary; note the tie briefly in rows.note. Use answer_only when the request asks for only the answer or a specific format: the reply is exactly the value(s) or table, with no basis, field names, note, or answer label. An unresolved answer retains its unable-to-determine status. Omit unused optional properties. ${renderedLengthGuidance} This tool is not available for JSON-schema requests; use StructuredOutput instead.`,
"Always supply `basis`; it is never shown when the request asks for only the answer",
95
95
)
96
96
expect(tool.description).toContain(
97
-
"one or two sentences naming population, grain, the source object/column that supplies the requested entity or value, and caveats",
97
+
"one or two sentences, at most 400 characters, naming population, grain, the source object/column that supplies the requested entity or value, and caveats",
98
98
)
99
99
expect(tool.description).toContain(
100
100
"Resolve policy eligibility separately from metric and entity attribution: a rule about a related object does not change which object supplies the requested entity. Say in `basis` which source object and column supply it.",
0 commit comments