Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
b2c0966
fix(translate): accept consecutively reported upstream choices
Menci Nov 11, 2026
dfb82f8
refactor(translate): expose prepared translation trips
Menci Nov 11, 2026
604abea
fix(protocols): condition input content on its message role
Menci Nov 11, 2026
6238b81
refactor(translate): clarify assistant-turn replay ownership
Menci Nov 11, 2026
e9d3098
fix(translate): preserve cross-protocol error details
Menci Nov 11, 2026
c94b6c4
refactor(translate): give output IR modules explicit ownership
Menci Nov 11, 2026
2c93c64
fix(translate): retain streaming error envelope metadata
Menci Nov 11, 2026
cdb444b
refactor(translate): finalize output event ownership
Menci Nov 11, 2026
d67c50d
merge: integrate role-conditioned protocol content
Menci Nov 11, 2026
ab856fb
merge: integrate named translation boundary
Menci Nov 11, 2026
287ef16
refactor(translate): finish replay contract ownership
Menci Nov 11, 2026
f446274
merge: integrate lossless upstream error fields
Menci Nov 11, 2026
0de5650
merge: integrate directional output ownership
Menci Nov 11, 2026
0e21359
merge: integrate sequential upstream choice handling
Menci Nov 11, 2026
3761019
merge: integrate native assistant-turn replay ownership
Menci Nov 11, 2026
b50a719
fix(translate): complete prerequisite integration contracts
Menci Nov 11, 2026
3807659
docs(translate): explain replay ownership contracts
Menci Nov 11, 2026
5ea091a
feat: translate requests through complete input IR
Menci Nov 11, 2026
2cd4023
test: retain replay and error coverage on input IR
Menci Nov 11, 2026
2e77d7c
refactor(translate): complete output IR cleanup
Menci Nov 11, 2026
fa83fa3
refactor(translate): give protocol errors dedicated owners
Menci Nov 12, 2026
2548bf0
fix(gateway): retain translation input error details
Menci Nov 12, 2026
f9eaf4e
Merge branch 'refactor/translate-public-boundary' into fix/translate-…
Menci Nov 12, 2026
d60f7d8
merge: update output ownership prerequisites
Menci Nov 12, 2026
d77d9f7
merge: update replay ownership documentation
Menci Nov 12, 2026
9b3d15b
merge: retain gateway input diagnostics
Menci Nov 12, 2026
8c3da3e
merge: isolate protocol error projection owners
Menci Nov 12, 2026
2f083af
merge: synchronize finalized translation prerequisites
Menci Nov 12, 2026
935b48d
docs(translate): clarify prepared trip integration boundaries
Menci Nov 12, 2026
d462a2b
docs: clarify input translation projection decisions
Menci Nov 12, 2026
c0b82c0
docs(translate): explain consecutive upstream choice indexes
Menci Nov 12, 2026
a399acd
test: align composed routes with finalized helper contracts
Menci Nov 12, 2026
20a3220
docs(translate): explain native error ownership contracts
Menci Nov 12, 2026
4792e62
docs(gateway): explain Gemini input error field carrier
Menci Nov 12, 2026
eb282f3
test: preserve upstream choice cardinality regressions
Menci Nov 12, 2026
2af4e52
Merge branch 'refactor/translate-public-boundary' into fix/translate-…
Menci Nov 12, 2026
dd936c1
test(translate): group output error ownership checks
Menci Nov 12, 2026
e9fc8a8
merge: refresh translation boundary documentation
Menci Nov 12, 2026
7c183cc
fix: reserve modern call IDs during legacy replay pairing
Menci Nov 12, 2026
96e1bac
merge: clarify error rendering contracts
Menci Nov 12, 2026
467637b
merge: document sequential choice semantics
Menci Nov 12, 2026
2ef17bb
merge: align output ownership test placement
Menci Nov 12, 2026
dc4be3a
test: retain signed replay and late usage protocol coverage
Menci Nov 12, 2026
af7e834
merge: synchronize final translation ownership contracts
Menci Nov 12, 2026
0ced6b8
test: retain the existing initialization regression path
Menci Nov 12, 2026
3317e0a
test: retain prerequisite event fixture ownership
Menci Nov 12, 2026
13305b6
fix(translate): retain the public translator contract
Menci Nov 12, 2026
b940339
refactor(gateway): remove the obsolete translation image adapter
Menci Nov 12, 2026
13703d2
refactor(translate): reuse the protocol JSON object guard
Menci Nov 12, 2026
f462664
refactor(protocols): own native request normalization
Menci Nov 12, 2026
f185e60
Merge branch 'refactor/translate-public-boundary' into fix/translate-…
Menci Nov 12, 2026
80e8a5c
refactor(protocols): own native assistant history normalization
Menci Nov 12, 2026
5056980
refactor(translate): use protocol status names in error projection
Menci Nov 12, 2026
6b8e515
Merge branch 'fix/translate-error-fields' into stack/translate-prereq…
Menci Nov 12, 2026
f2a0d1e
Merge branch 'refactor/translate-replay' into stack/translate-prerequ…
Menci Nov 12, 2026
145fba9
Merge branch 'refactor/translate-protocol-lint' into stack/translate-…
Menci Nov 12, 2026
109c374
style: align merged protocol boundary imports
Menci Nov 12, 2026
5fa4025
merge: synchronize protocol normalization ownership
Menci Nov 12, 2026
a6f4957
fix(copilot): preserve refusals in retained compaction history
Menci Nov 12, 2026
27a1b04
Merge branch 'fix/protocol-content-roles' into stack/translate-prereq…
Menci Nov 12, 2026
489d734
Merge branch 'stack/translate-prerequisites' into feat/fit-ir-input
Menci Nov 12, 2026
1a97839
fix(translate): accept case-insensitive HTTP image schemes
Menci Nov 12, 2026
1a8c049
fix(gateway): retain token-counting input failure telemetry
Menci Nov 12, 2026
508c2e1
fix(translate): preserve colliding error metadata
Menci Nov 12, 2026
7647110
Merge branch 'refactor/translate-public-boundary' into fix/translate-…
Menci Nov 12, 2026
15a8c5d
Merge branch 'fix/translate-error-fields' into stack/translate-prereq…
Menci Nov 12, 2026
c8d8615
Merge branch 'stack/translate-prerequisites' into feat/fit-ir-input
Menci Nov 12, 2026
7879f76
style(translate): order integrated error helper imports
Menci Nov 12, 2026
00ca767
Merge branch 'stack/translate-prerequisites' into feat/fit-ir-input
Menci Nov 12, 2026
8b4714a
fix(translate): use the protocol status for upstream 502 errors
Menci Nov 12, 2026
368c417
fix(gateway): preserve Responses continuation errors
Menci Nov 12, 2026
32070c5
Merge branch 'fix/translate-error-fields' into stack/translate-prereq…
Menci Nov 12, 2026
37cbe93
Merge branch 'stack/translate-prerequisites' into feat/fit-ir-input
Menci Nov 12, 2026
cd91463
fix(gateway): classify collected Responses errors
Menci Nov 12, 2026
e06543a
Merge branch 'fix/translate-error-fields' into stack/translate-prereq…
Menci Nov 12, 2026
883df88
Merge branch 'stack/translate-prerequisites' into feat/fit-ir-input
Menci Nov 12, 2026
3810353
fix(translate): resolve redeclared Responses tools to their latest de…
Menci Nov 12, 2026
912c734
merge: synchronize input IR with main
Menci Nov 12, 2026
781820c
fix(translate): state both Chat token limit spellings
Menci Nov 12, 2026
eb622b9
fix(translate): preserve input media source values
Menci Nov 12, 2026
f8a8b1b
fix(translate): distinguish instructions from prompt history
Menci Nov 12, 2026
b550ccd
fix(translate): preserve client message and null semantics
Menci Nov 12, 2026
196bd4b
fix(translate): retain source tool restriction behavior
Menci Nov 12, 2026
03056ba
fix(translate): preserve structured tool-result history
Menci Nov 12, 2026
2af06eb
fix(translate): keep restored turns target-native
Menci Nov 12, 2026
ebc762a
fix(translate): keep Gemini thought visibility source-side
Menci Nov 12, 2026
dcaae60
test(translate): align result projection regressions
Menci Nov 12, 2026
e71cbef
test(translate): align fixtures with finalized input semantics
Menci Nov 12, 2026
be96b77
fix(translate): preserve input semantics across targets
Menci Nov 12, 2026
b51fcff
fix(translate): complete input edge semantics
Menci Nov 12, 2026
0f4fad2
fix(translate): close cross-protocol behavior gaps
Menci Nov 12, 2026
f900798
test(translate): align suite with finalized input semantics
Menci Nov 12, 2026
7c29302
revert(translate): remove text block boundary marker
Menci Nov 12, 2026
7038bee
fix(translate): restore authorized instruction and reasoning semantics
Menci Nov 12, 2026
eb1134f
feat(translate): preserve document structure in input IR
Menci Nov 12, 2026
cfcbaef
refactor(translate): trim input IR commentary
Menci Nov 12, 2026
764a99f
docs(translate): mark input IR protocol coverage
Menci Nov 12, 2026
fc2d2cb
refactor(translate): simplify input translation
Menci Nov 12, 2026
750b4bd
fix(translate): preserve document and tool format semantics
Menci Nov 13, 2026
0e0c1f9
fix(translate): update streamed callable identities
Menci Nov 13, 2026
42dc09a
test(translate): enforce stable Responses tool identities
Menci Nov 13, 2026
0c60719
Merge remote-tracking branch 'origin/feat/fit-ir-input' into fix/resp…
Menci Nov 13, 2026
96dd5c6
Merge remote-tracking branch 'origin/main' into fix/responses-tool-re…
Menci Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions packages/translate/src/composition/request/tool-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ export const allocateToolNames = <Restored>(
request: IRInputRequestHeader,
inputTurns: readonly (IRInputTurnWithCallIds | RestoredAssistantTurn<Restored>)[],
): { readonly request: IRInputRequestHeader; readonly turns: readonly (IRInputTurnWithCallIds | RestoredAssistantTurn<Restored>)[]; readonly context: ToolNameContext } => {
const declared = new Set<string>();
for (const tool of request.tools ?? []) {
const key = callableKey(tool);
// One identity allocates one name, and these wires reject a repeated declaration name.
if (declared.has(key)) throw new TranslateInputException(`Cannot translate repeated declarations of tool '${tool.name}'.`);
declared.add(key);
}
const callables = [
...(request.tools ?? []),
...inputTurns.flatMap(turn => turn.kind === 'restored' ? [] : turn.items.flatMap(item =>
Expand Down
3 changes: 2 additions & 1 deletion packages/translate/src/ir/input/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export interface IRInputOutputFormat {
// All
export interface IRInputRequestHeader {
readonly settings: IRInputSettings; // All
// Absent and empty are the same thing: a request that declares no tool.
// Absent and empty are the same thing: a request that declares no tool. Each
// callable identity appears once; a source that allows redeclaration resolves it.
readonly tools?: readonly IRInputTool[]; // All
readonly tool_choice?: IRInputToolChoice; // All
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,10 @@ const selectorOf = (payload: CanonicalOpenAIResponsesPayload, selector: Record<s
if (typeof selector.name !== 'string' || Object.keys(selector).some(key => key !== 'type' && key !== 'name')) {
throw new TranslateInputException('Cannot translate namespace selector extensions.');
}
const groups = [
...(payload.tools ?? []),
...payload.input.flatMap(item => item.type === 'additional_tools' || item.type === 'tool_search_output' ? item.tools : []),
].flatMap(tool => tool.type === 'namespace' && tool.name === selector.name ? [tool] : []);
if (groups.length === 0) throw new TranslateInputException(`Cannot translate group selector '${String(selector.name)}' without a matching declaration.`);
return groups.flatMap(group => group.tools.flatMap(child => child.type === 'function' || child.type === 'custom'
? [{ type: child.type, name: child.name, namespace: group.name } as IRInputToolSelector]
: []));
if (!toolInventories(payload).some(tool => tool.type === 'namespace' && tool.name === selector.name)) {
throw new TranslateInputException(`Cannot translate group selector '${String(selector.name)}' without a matching declaration.`);
}
return declarations.flatMap(({ type, namespace, name }) => namespace === selector.name ? [{ type, namespace, name }] : []);
};

const toolChoiceToIR = (
Expand Down Expand Up @@ -296,14 +292,22 @@ const toolGroupToIR = (tool: OpenAIResponsesTool): IRInputTool[] => {

// A request can defer declarations to an inventory item inside the
// conversation; those are tools like any other, not things the model said.
const deferredInventories = (payload: CanonicalOpenAIResponsesPayload): OpenAIResponsesTool[] =>
payload.input.flatMap(item => item.type === 'additional_tools' || item.type === 'tool_search_output' ? item.tools : []);
const toolInventories = (payload: CanonicalOpenAIResponsesPayload): OpenAIResponsesTool[] => [
...(payload.tools ?? []),
...payload.input.flatMap(item => item.type === 'additional_tools' || item.type === 'tool_search_output' ? item.tools : []),
];

// Codex declares a namespace in `tools`, again in `additional_tools`, and once
// more after each compaction, so one callable can arrive many times. The latest
// declaration is the caller's current statement of it; it takes the slot of the
// first, which keeps the declared prefix stable for prompt caching.
const latestDeclarations = (tools: readonly IRInputTool[]): IRInputTool[] =>
[...new Map(tools.map(tool => [JSON.stringify([tool.type, tool.namespace, tool.name]), tool])).values()];

const openaiResponsesToolsToIR = (payload: CanonicalOpenAIResponsesPayload): Pick<IRInputRequestHeader, 'tools' | 'tool_choice'> => {
const declared = payload.tools?.flatMap(toolGroupToIR) ?? [];
const deferred = deferredInventories(payload).flatMap(toolGroupToIR);
const tools = declared.length === 0 && deferred.length === 0 ? undefined : [...declared, ...deferred];
const toolChoice = payload.tool_choice == null ? undefined : toolChoiceToIR(payload, payload.tool_choice, tools ?? []);
const declarations = latestDeclarations(toolInventories(payload).flatMap(toolGroupToIR));
const tools = declarations.length === 0 ? undefined : declarations;
const toolChoice = payload.tool_choice == null ? undefined : toolChoiceToIR(payload, payload.tool_choice, declarations);
return {
...(tools === undefined ? {} : { tools }),
...(toolChoice === undefined ? {} : { tool_choice: toolChoice }),
Expand Down
Loading