Fix gateway fields#38
Conversation
Greptile SummaryThis PR introduces server-side conversation reconstruction from
Confidence Score: 5/5Safe to merge — the two container-binding breakages from the prior review are both fixed, and the new chain reconstruction, gateway-field stripping, and echo-field restoration are well-tested and logically sound. The reconstruction logic hard-errors on corrupt records rather than silently dropping turns, the original_previous_response_id stash is applied consistently in all four lookup sites, and strip_gateway_fields is backed by a unit test. No new defects were found. No files require special attention. The most complex new code (responses_chain.rs and the echo-field rewrite path in response_persister.rs) is well-covered by unit tests. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant ChatRoute as chat.rs
participant Chain as responses_chain.rs
participant Store as ResponsesStore
participant Provider as Upstream Provider
participant Persister as response_persister.rs
Client->>ChatRoute: "POST /responses {previous_response_id, input}"
Note over ChatRoute: Stash original_previous_response_id & original_input
ChatRoute->>Chain: reconstruct_input(store, org_id, prev_id, current_input)
loop Walk chain newest to oldest
Chain->>Store: get(id, org_id)
Store-->>Chain: ResponseRecord
end
Chain-->>ChatRoute: "Vec<ResponsesInputItem> (full transcript)"
Note over ChatRoute: payload.input = reconstructed, payload.previous_response_id = None
ChatRoute->>Provider: POST /responses (strip_gateway_fields applied)
alt Streaming
Provider-->>Persister: SSE events
Note over Persister: rewrite_lifecycle_echo_fields: id, store, previous_response_id restored
Persister-->>Client: SSE events (echo fields restored)
Persister->>Store: Persist final state
else Non-streaming
Provider-->>ChatRoute: JSON body
Note over ChatRoute: apply_response_echo_fields patches id, store, previous_response_id
ChatRoute-->>Client: JSON body (echo fields restored)
ChatRoute->>Store: Persist with original_input + original_previous_response_id
end
Reviews (6): Last reviewed commit: "Review fixes" | Re-trigger Greptile |
No description provided.