Summary
Droid can crash while finalizing streamed BYOK OpenAI Responses turns when the response contains invalid or sparse tool/content block state.
Observed error:
TypeError: undefined is not an object (evaluating 'f.type')
The same failure class sometimes appears as E.type.
This correlates with Droid logging filtered invalid tool uses immediately before finalization:
[LLM] Filtered out invalid tool uses ... invalidTools=[{}, ...]
Environment
- OS: Windows
win32 10.0.26200
- Droid version in logs:
0.121.0
- BYOK: true
- Endpoint shape: OpenAI-compatible
/v1/responses
- Affected surfaces observed locally:
- Factory Desktop / daemon session
- Droid CLI sessions
- Zed Droid / ACP wrapper
Reproduction pattern
- Configure Droid with a BYOK OpenAI-compatible
/v1/responses model.
- Run a tool-heavy agent task where the assistant may emit tool calls.
- The stream completes far enough for Droid to process tool-use state.
- Logs show invalid tool uses being filtered, often serialized as empty objects.
- Droid crashes in/around final content-block finalization with
f.type / E.type instead of surfacing a typed assistant message or a recoverable model/tool error.
Structural evidence
Representative sanitized metadata from local logs:
errorMessage: undefined is not an object (evaluating 'f.type')
version: 0.121.0
platform: win32
isByok: true
outputFormat: stream-jsonrpc
preceding invalid tools: totalTools=4 validTools=1 invalidTools=[{},{},{}]
Other occurrences had larger invalid-tool counts such as totalTools=12 validTools=5 invalidTools=[{} x7] and totalTools=30 validTools=3 invalidTools=[{} x27].
No prompts, API keys, OAuth credentials, account identifiers, tool inputs, or full session JSONL payloads are included here.
Expected behavior
- Droid should not crash with a raw
.type TypeError when it sees invalid or sparse BYOK stream state.
- Invalid model/tool/content blocks should be discarded, compacted, or converted into a typed recoverable error.
- If the BYOK stream is rejected, the user should see a clear recoverable stream-shape error.
- Logs should report the offending structural path without exposing prompt/tool content.
Server-side mitigations tried
On the BYOK gateway side, I tested/added mitigations for known stream-shape problems:
- JSON-mode guard for default
web_search;
- Responses
tool_choice compatibility;
- top-level stream error envelopes;
- malformed output-item guards;
function_call.call_id normalization;
- canonical Responses stream mode with dense local
output_index values.
Dense canonical indexes reduced/avoided one observed sparse-index crash path in fresh smoke testing, but Droid should still handle invalid BYOK stream shapes gracefully instead of throwing f.type / E.type.
Separate related symptom
A later image-generation attempt spun in a no-visible-output loop, but current evidence did not show a real image_generation_call invocation. I am treating that as a separate session-runner/no-visible-output issue unless it reproduces with a clear image-generation stream event.
Summary
Droid can crash while finalizing streamed BYOK OpenAI Responses turns when the response contains invalid or sparse tool/content block state.
Observed error:
The same failure class sometimes appears as
E.type.This correlates with Droid logging filtered invalid tool uses immediately before finalization:
Environment
win32 10.0.262000.121.0/v1/responsesReproduction pattern
/v1/responsesmodel.f.type/E.typeinstead of surfacing a typed assistant message or a recoverable model/tool error.Structural evidence
Representative sanitized metadata from local logs:
Other occurrences had larger invalid-tool counts such as
totalTools=12 validTools=5 invalidTools=[{} x7]andtotalTools=30 validTools=3 invalidTools=[{} x27].No prompts, API keys, OAuth credentials, account identifiers, tool inputs, or full session JSONL payloads are included here.
Expected behavior
.typeTypeError when it sees invalid or sparse BYOK stream state.Server-side mitigations tried
On the BYOK gateway side, I tested/added mitigations for known stream-shape problems:
web_search;tool_choicecompatibility;function_call.call_idnormalization;output_indexvalues.Dense canonical indexes reduced/avoided one observed sparse-index crash path in fresh smoke testing, but Droid should still handle invalid BYOK stream shapes gracefully instead of throwing
f.type/E.type.Separate related symptom
A later image-generation attempt spun in a no-visible-output loop, but current evidence did not show a real
image_generation_callinvocation. I am treating that as a separate session-runner/no-visible-output issue unless it reproduces with a clear image-generation stream event.