Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion agent/codex_responses_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def _derive_responses_function_call_id(
return f"fc_{sanitized[:48]}"

seed = source or str(response_item_id or "") or uuid.uuid4().hex
digest = hashlib.sha1(seed.encode("utf-8")).hexdigest()[:24]
digest = hashlib.sha1(seed.encode("utf-8"), usedforsecurity=False).hexdigest()[:24]
return f"fc_{digest}"


Expand Down
2 changes: 1 addition & 1 deletion agent/context_compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ def _prune_old_tool_results(
continue
if len(content) < 200:
continue
h = hashlib.md5(content.encode("utf-8", errors="replace")).hexdigest()[:12]
h = hashlib.md5(content.encode("utf-8", errors="replace"), usedforsecurity=False).hexdigest()[:12]
if h in content_hashes:
# This is an older duplicate — replace with back-reference
result[i] = {**msg, "content": "[Duplicate tool output — same content as a more recent call]"}
Expand Down
3 changes: 2 additions & 1 deletion agent/transports/codex_app_server_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@ def run_turn(
# turn re-spawns cleanly.
result.should_retire = True
return result
assert self._client is not None and self._thread_id is not None
if self._client is None or self._thread_id is None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compact_thread() repeats this exact post-ensure_started() assertion at current main agent/transports/codex_app_server_session.py:661. Please apply the same handling there, or centralize the shared invariant, if this PR is intended to harden these production paths under python -O.

raise RuntimeError("codex session not initialised — call connect() first")
result.thread_id = self._thread_id

self._interrupt_event.clear()
Expand Down
3 changes: 2 additions & 1 deletion tui_gateway/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5850,7 +5850,8 @@ def _(rid, params: dict) -> dict:
session, err = _sess_nowait({"session_id": sid}, rid)
if err:
return err
assert session is not None
if session is None:
return _err(rid, -32000, "session not found or unavailable")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_sess_nowait() already returns an error whenever session is None, and the preceding if err: return err exits first. This fallback is unreachable; remove the redundant assertion instead of introducing a second missing-session error contract.

return _ok(
rid,
Expand Down
Loading