Skip to content

Commit 9ae743f

Browse files
Docs(dev): ApplyPatch + OpenAI Responses integration notes
- Capture design choices, telemetry observations, and pending items - Reference PR #1166 and branch name for continuity Co-authored-by: openhands <[email protected]>
1 parent f08a048 commit 9ae743f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# ApplyPatch + OpenAI Responses Integration Notes
2+
3+
Status: in progress
4+
Branch: feat/apply-patch-tool-gpt5-1
5+
PR: https://github.com/OpenHands/software-agent-sdk/pull/1166
6+
7+
## Overview
8+
9+
We integrated an ApplyPatch tool modeled after OpenAI's cookbook for GPT-5.1 "server-known" tools. The SDK advertises a minimal function tool schema to nudge the model to include a `patch` argument while relying on OpenAI's server-side tool definitions.
10+
11+
## Key decisions
12+
13+
- ToolDefinition.to_responses_tool returns a minimal schema:
14+
-
15+
- Accept both `patch` and `patch_text` via Pydantic aliasing; serialize as `patch`.
16+
- Example targets `openai/gpt-5.1-codex-mini` and uses the OPENAI_API_KEY from env.
17+
18+
## Responses pipeline adjustments
19+
20+
- Do not echo prior-turn `reasoning` items in input; this can violate ordering constraints.
21+
- Include assistant `function_call` items in the input and the paired `function_call_output` items produced by tools. This satisfies the server's validation that an output must correspond to a previous call in the same input batch.
22+
23+
## Remaining issue
24+
25+
- We still observe a 400 "No tool call found for function call output with call_id ...". This suggests a mismatch between assistant function_call ids and our tool function_call_output call_id, or we failed to include the assistant call in the same input batch.
26+
- Next steps: add tests for the Responses input assembly to ensure assistant function_call and tool function_call_output appear together and ids match.
27+
28+
## Cross-check with FileEditor
29+
30+
- Review FileEditor tool integration for execution and event serialization, ensuring ApplyPatch mirrors the same error-path handling (e.g., AgentErrorEvent on validation errors).
31+
32+
## Testing plan
33+
34+
- Unit tests for ApplyPatch executor: create/append/delete flows using minimal patches.
35+
- Serialization tests for Responses: verify that given an assistant function_call and a tool observation, `format_messages_for_responses` outputs `function_call` then `function_call_output` with matching ids and no reasoning echoes.
36+
37+
## Telemetry tips
38+
39+
- Enable `log_completions=True` to inspect requests/responses under `logs/completions/`.
40+
- Compare call_id values across turns and ensure consistency.

0 commit comments

Comments
 (0)