Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
16265ea
Allow bounded editing of native request presentation
markstuart-oai Nov 5, 2026
1a2b6cc
Send a real failed SSE response in the request recovery test
markstuart-oai Nov 5, 2026
23304dd
Report rejected request-editor compaction after a tool call
markstuart-oai Nov 5, 2026
f2e3810
fix(agents): enforce prepared-request operation boundaries
markstuart-oai Nov 5, 2026
3e57244
chore(agents): integrate native trace context base
markstuart-oai Nov 5, 2026
1831525
fix(agents): validate the sampled request-editor tool roster
markstuart-oai Nov 5, 2026
24a008c
fix(agents): preserve prepared schemas on the current history base
markstuart-oai Nov 5, 2026
b8b0da5
fix(a2a): reject encoded responses before body reads
markstuart-oai Nov 5, 2026
7d5fac8
Merge native context and model defaults into request editing
markstuart-oai Nov 5, 2026
02aba47
fix(a2a): preserve serialized structured results
markstuart-oai Nov 5, 2026
21e6bea
Compose request editing with native workflow tracing
markstuart-oai Nov 5, 2026
291d975
Bound authentication recovery across transport fallback
markstuart-oai Nov 5, 2026
ce6124e
Read the realtime pairing test request count from the token server
markstuart-oai Nov 5, 2026
9fe19f8
Compose prepared requests with the extracted Codex runtime
markstuart-oai Nov 5, 2026
e1a40fe
Merge the SessionStore runtime and allow the API coverage fixture to …
markstuart-oai Nov 5, 2026
fe13809
Integrate current session storage and verify sampling authentication …
markstuart-oai Nov 5, 2026
231f7a6
Merge current worker quota example updates
markstuart-oai Nov 5, 2026
a1cf78b
Compose request preparation with durable storage and single error set…
markstuart-oai Nov 5, 2026
c545b8e
Merge remote-tracking branch 'origin/feat/codex-harness' into codex/n…
markstuart-oai Nov 5, 2026
1e311e3
chore: merge Codex package extraction into A2A response guard
markstuart-oai Nov 5, 2026
d16fcb3
Integrate the owned-child tracing fix with the A2A adapter
markstuart-oai Nov 5, 2026
ae0b48e
Preserve current native tracing in request preparation
markstuart-oai Nov 5, 2026
f567ccd
Integrate current tracing ownership fix into authentication recovery
markstuart-oai Nov 5, 2026
37e5fd0
Merge current native OpenSSL fixture isolation
markstuart-oai Nov 5, 2026
d3a9cc4
Await the Core carrier close handshake before sampling reconnect
markstuart-oai Nov 5, 2026
dfbee78
chore: integrate current child tracing policy into A2A response guard
markstuart-oai Nov 5, 2026
61d83aa
Integrate the macOS executor HTTP probe fix
markstuart-oai Nov 5, 2026
a6ca3cd
Merge remote-tracking branch 'origin/feat/codex-harness' into codex/n…
markstuart-oai Nov 5, 2026
b5c2b46
Retain the native workflow policy through queued child submissions
markstuart-oai Nov 5, 2026
b182783
Use the owning turn for executor approval tracing
markstuart-oai Nov 5, 2026
f367048
Assert the denied child command stops before executor dispatch
markstuart-oai Nov 5, 2026
8206687
Exercise independent ambient and instrumented trace contexts
markstuart-oai Nov 5, 2026
48aa8a1
Integrate native child tracing with A2A structured results
markstuart-oai Nov 5, 2026
39806a9
Merge child tracing isolation repair into A2A response encoding
markstuart-oai Nov 5, 2026
c1a8897
Compose request preparation with owned child tracing
markstuart-oai Nov 5, 2026
2e4cbf6
Merge owned child tracing context into authentication retry
markstuart-oai Nov 5, 2026
44f6e78
Preserve child callback ownership across queued submissions and execu…
markstuart-oai Nov 5, 2026
64bc380
Integrate native child callback ownership with A2A structured results
markstuart-oai Nov 5, 2026
ee5d40c
Preserve prepared requests on the reconciled child tracing base
markstuart-oai Nov 5, 2026
a580fde
Merge current v1 child tracing ownership fix
markstuart-oai Nov 5, 2026
82d821a
Merge current child callback ownership integration
markstuart-oai Nov 5, 2026
b723a82
Keep W3C trace ancestry separate from workflow export settings
markstuart-oai Nov 5, 2026
f58b643
Integrate native trace-policy isolation with A2A structured results
markstuart-oai Nov 5, 2026
d5b24dc
Carry the admitted caller context through native child operations
markstuart-oai Nov 5, 2026
2fec101
Preserve admitted caller context for A2A structured results
markstuart-oai Nov 5, 2026
8817185
Preserve prepared requests on the private caller-owned tracing prefix
markstuart-oai Nov 5, 2026
05c403a
Bind cancellation to the admitted turn context
markstuart-oai Nov 5, 2026
6fcf2b3
Verify export routing through the public tracing API
markstuart-oai Nov 5, 2026
b287ca0
Integrate explicit native trace ownership into authentication retry
markstuart-oai Nov 5, 2026
6d01bd0
fix: wait for settled native child admission
markstuart-oai Nov 5, 2026
1875314
Merge commit 'b8a51306ccceea0da5553703fef14a5afe3f8fb4' into codex/v1…
markstuart-oai Nov 5, 2026
c5971ad
fix: integrate queued tracing into response encoding
markstuart-oai Nov 5, 2026
a560d1e
fix: integrate response encoding and queued tracing into structured r…
markstuart-oai Nov 5, 2026
15b9bf5
fix: integrate A2A and corrected child tracing into auth recovery
markstuart-oai Nov 5, 2026
4f7b49f
fix: integrate auth recovery and queued tracing into request preparation
markstuart-oai Nov 5, 2026
505ba70
Integrate request preparation with current auth candidate
markstuart-oai Nov 5, 2026
f563352
Integrate request preparation with current v1
markstuart-oai Nov 5, 2026
ea8a96e
Preserve raw managed schemas in prepared requests
markstuart-oai Nov 5, 2026
8edad04
Preserve completed answers when skipping prepared post-turn compaction
markstuart-oai Nov 5, 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
5 changes: 5 additions & 0 deletions .changeset/native-prepared-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openai/agents': minor
---

feat: Add per-operation prepared-request editing for native HTTP root conversations while preserving original tool and history authority.
114 changes: 114 additions & 0 deletions packages/agents/examples/prepared-request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import assert from 'node:assert/strict';
import { z } from 'zod';
import { Agent, Runner, ToolOutput, tool } from '@openai/agents';
import { text, toolCall, withScriptedResponses } from '@openai/agents/testing';

/**
* Exercise the public request, argument and result controls without live credentials.
* The scripted provider uses explicit HTTP and a standard Responses (non-Lite) model.
* Select eager ordinary tools for each sampling step of a direct root.
* beforeStep may narrow a mixed opening catalog. Deferred sampled tools fail before the editor.
* Environment, code mode, children and automatic compaction are outside this profile.
* Pre-turn or mid-turn automatic compaction fails before any hidden model request.
* Shorten the input or start a new operation without the callback. Earlier tool effects remain.
* Post-turn compaction is refused while preserving the completed answer.
* Supply new input to Agent.run when using prepareRequest. A resumed turn cannot add an editor.
* Sampling edits do not change canonical history, executable schemas or policies.
* For structured output, use native mode or prompted mode with maxRetries: 0.
*/
export async function runPreparedRequestExample(): Promise<string> {
const effects: string[] = [];
const lookup = tool({
name: 'lookup',
description: 'Look up a synthetic record.',
parameters: z.object({ key: z.enum(['allowed']), label: z.string() }),
before: ({ callId, originalArguments }) => {
assert.equal(callId, 'lookup');
assert.deepEqual(originalArguments, {
key: 'allowed',
label: 'original',
});
return {
action: 'replaceArguments',
arguments: { key: 'allowed' as const, label: 'corrected' },
};
},
execute: ({ key, label }) => {
effects.push(label);
return `Raw record ${key}`;
},
after: (_output, { callId, effectiveArguments }) => {
assert.equal(callId, 'lookup');
assert.equal(effectiveArguments.label, 'corrected');
return new ToolOutput([{ type: 'inputText', text: 'SHAPED_RESULT' }]);
},
});
return withScriptedResponses(
[
[
toolCall(
'lookup',
{ key: 'allowed', label: 'original' },
{ callId: 'lookup' },
),
],
[text('The record is allowed.')],
],
async (peer) => {
const result = await Runner.run(
new Agent({
model: 'gpt-5.5',
instructions: 'Call lookup, then explain its result.',
provider: peer.provider,
tools: [lookup],
}),
'Look up the record.',
{
prepareRequest({ request, signal }) {
signal.throwIfAborted();
// Recovery can advance the index without a result. Inspect native input.
if (
!request.input.some(
(item) =>
item !== null &&
typeof item === 'object' &&
!Array.isArray(item) &&
item.type === 'function_call_output' &&
item.call_id === 'lookup',
)
)
return;
request.instructions = 'Explain the lookup result in one sentence.';
request.input.push({
type: 'message',
role: 'user',
content: [{ type: 'input_text', text: 'SAMPLING_ONLY_NOTE' }],
});
request.tools[0].description = 'Sampled record description.';
request.tools[0].parameters.properties = {
key: { type: 'string', enum: ['allowed', 'sampled-only'] },
label: { type: 'string' },
};
return request;
},
},
);
assert.deepEqual(effects, ['corrected']);
assert.equal(peer.toolOutput('lookup'), 'SHAPED_RESULT');
assert.equal(peer.requests.length, 2);
assert.match(
JSON.stringify(peer.requests[1].input),
/SAMPLING_ONLY_NOTE/,
);
assert.match(
JSON.stringify(peer.requests[1].tools),
/Sampled record description/,
);
assert.match(
JSON.stringify(peer.requests[1].input),
/Explain the lookup result in one sentence/,
);
return result.finalOutput;
},
);
}
3 changes: 2 additions & 1 deletion packages/agents/native/Cargo.lock

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

1 change: 1 addition & 0 deletions packages/agents/native/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export class NativeThread {
arguments_: string,
traceJson?: string | null,
): Promise<string>;
_reply_prepared_request(responseJson: string): void;
_reply_step(response_json: string): void;
_check_step(response_json: string): boolean;
_reply_child_step(response_json: string): boolean;
Expand Down
Loading