Merged
Conversation
Dialyzer (newly enabled on this branch) flagged Session.stream/3
as invalid_contract: the function was storing a make_ref() in the
`session_id` field, which is typed as `String.t() | nil`.
Beyond the type mismatch, the underlying multi-turn-via-stream
mechanism was broken in three ways:
1. The reference placeholder meant the caller's returned session
had a non-binary session_id, so any follow-up Session.send/3
would fail the `when is_binary(sid)` guard in execute_turn.
2. maybe_capture_session_id/3 sent {ref, :session_id, sid}
messages to the parent process but nothing ever received them.
3. It looked up "session_id" in event data, but Codex 0.119+
emits the thread identifier as "thread_id", not "session_id",
so even if the capture wired up correctly it would see nil.
The function is untested and the chain `Session.stream -> Session.send`
could never have worked. Rather than rebuilding the capture
machinery, return the session unchanged and document that
`stream/3` does not thread session_id — callers who need
multi-turn continuity should use `send/3`, which runs the turn
synchronously and updates session_id from the final events.
Removes the now-unused maybe_capture_session_id/3 helper.
Note: Session.send/3 has a related (but separate) bug where
`extract_session_id` also looks for "session_id" instead of
"thread_id", which means multi-turn via Session.send is silently
broken against Codex 0.119+. That is a runtime bug, not a
dialyzer issue, and will be fixed in a follow-up.
b8ff7fa to
31686a4
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
mix compile --warnings-as-errorspassesmix dialyzercompletes