Skip to content

chore(sync): adapt to upstream v0.82.1 - #4

Merged
encyc merged 1 commit into
mainfrom
codex/pi-0.82.1-adaptation
Jul 27, 2026
Merged

chore(sync): adapt to upstream v0.82.1#4
encyc merged 1 commit into
mainfrom
codex/pi-0.82.1-adaptation

Conversation

@encyc

@encyc encyc commented Jul 27, 2026

Copy link
Copy Markdown
Owner

What changed

  • bump all five Python packages and internal dependency ranges to upstream v0.82.1
  • add constrained tool sampling for strict JSON Schema and OpenAI Lark/regex grammar tools
  • add abortable provider-request retries and DNS transport error classification
  • isolate compaction summary routing sessions and disable prompt-cache writes
  • update sync history, changelog, lockfile, tests, and porting notes

Why

Upstream pi v0.82.1 introduced constrained sampling, provider retry behavior changes, and compaction cache/session isolation that required corresponding Python SDK compatibility updates.

Validation

  • uv run ruff check
  • uv run ruff format --check
  • uv run python -m mypy
  • uv run python -m pytest — 207 passed, 14 integration tests deselected
  • real DeepSeek API integration suite — 11 passed, covering streaming, tool calls, agent loops, compaction, and coding tools

@encyc
encyc marked this pull request as ready for review July 27, 2026 03:49
@encyc
encyc merged commit f562b87 into main Jul 27, 2026
3 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e71a288e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +47 to +50
status = _status(error)
if status is None:
return hasattr(error, "status_code") or hasattr(error, "status")
return status in {408, 409, 429} or status >= 500

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retry SDK connection exceptions without HTTP status

When max_retries is positive and OpenAI or Anthropic raises APIConnectionError/APITimeoutError, these SDK exceptions generally have neither status_code nor status, so this branch returns false and the request is never retried. These transient connection and timeout failures should be classified as retryable explicitly rather than relying on HTTP-status attributes.

Useful? React with 👍 / 👎.

Comment on lines +419 to +421
max_retries=(options.max_retries or 0) if options else 0,
max_retry_delay_ms=options.max_retry_delay_ms if options else None,
cancel_event=options.cancel_event if options else None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Pass the agent cancel event to provider options

When a provider is invoked through Agent, Agent.abort() sets the event passed into _stream_assistant_response, but that function constructs SimpleStreamOptions without cancel_event; consequently this expression always receives None and an in-progress provider retry backoff cannot be interrupted. Forward the loop's cancellation event into the stream options used by both providers.

Useful? React with 👍 / 👎.

Comment on lines +93 to +95
task.cancel()
if cancelled in done:
raise asyncio.CancelledError

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve aborted semantics when retry sleep is cancelled

When a caller supplies cancel_event and sets it during retry backoff, this raises CancelledError, but both provider drive() functions catch BaseException and convert it into an ErrorEvent(reason="error") with stop_reason="error" (usually with an empty message). Consumers therefore see a provider failure rather than the supported aborted terminal state; handle cancellation separately in the providers and emit the aborted result.

Useful? React with 👍 / 👎.

Comment on lines +73 to +78
try:
delay = float(retry_after) * 1000
except ValueError:
parsed = email.utils.parsedate_to_datetime(retry_after)
delay = float(parsed.timestamp()) * 1000 - time.time() * 1000
return _validate_delay(delay, maximum, str(error))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fall back when Retry-After is malformed

When a retryable response from a compatible provider or proxy contains a nonnumeric, malformed Retry-After value, parsedate_to_datetime() raises ValueError here and aborts the request instead of using the exponential fallback despite retries remaining. Treat an unparseable HTTP-date like an absent header so transient failures can still be retried.

Useful? React with 👍 / 👎.

Comment on lines +191 to +194
isolated_options = {
**options,
"session_id": str(uuid.uuid4()),
"cache_retention": "none",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply compaction isolation options in built-in providers

When compaction uses either built-in OpenAI or Anthropic provider, these newly assigned values do not isolate anything because neither provider reads session_id or cache_retention when building its request (the fields otherwise only occur in the option models). The summary therefore uses the provider's normal routing and cache behavior despite the random session and none retention; translate these options into the appropriate request parameters or headers before relying on them here.

Useful? React with 👍 / 👎.

@encyc
encyc deleted the codex/pi-0.82.1-adaptation branch July 30, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant