Skip to content

Align WorkBuddy 5.9.3 client contract - #103

Merged
maiphucgiang merged 1 commit into
mainfrom
feat/cn-work-593-contract
Oct 29, 2026
Merged

maiphucgiang merged 1 commit into
mainfrom
feat/cn-work-593-contract

Conversation

@maiphucgiang

@maiphucgiang maiphucgiang commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Align domestic WorkBuddy with the 5.9.3 request contract: runtime, baggage, ACP, stable UUIDv7 session IDs, per-attempt tracing and non-chat request IDs.
  • Scope private-data and identity headers to the real account and JWT metadata, mark automated calls as auxiliary, and preserve the verified CLI and international profile differences.
  • Add replay-safe gzip only to official chat endpoints: CLI and international WorkBuddy always use it, while domestic WorkBuddy uses it at 1024 bytes. Preview decodes gzip; media, search and fetch keep their original transport.
  • Refresh the growth event fingerprint to 5.9.3 and update the English/Chinese behavior docs and regression coverage.

Tests

  • uv run python -B -m pytest -q tests/ — 2371 passed, 2 skipped, 5323 subtests passed.

Summary by Sourcery

Align domestic WorkBuddy integration with the verified 5.9.3 client contract while preserving existing profile-specific behavior.

Bug Fixes:

  • Align domestic WorkBuddy request handling with the 5.9.3 client contract.

Enhancements:

  • Add profile-specific session, identity, tracing, ACP, baggage, and request-header behavior while preserving CLI and international differences.
  • Apply deterministic gzip encoding to supported chat requests and decode compressed payloads in the preview service.
  • Refresh WorkBuddy 5.9.3 growth-event metadata and update related documentation and regression coverage.

Documentation:

  • Update English and Chinese advanced behavior documentation for the WorkBuddy 5.9.3 contract and transport behavior.

Tests:

  • Expand regression coverage for profile-specific headers, stable session IDs, tracing, gzip transport, growth metadata, and compressed request decoding.

@maiphucgiang
maiphucgiang merged commit 8ccc17e into main Oct 29, 2026
8 checks passed
@maiphucgiang
maiphucgiang deleted the feat/cn-work-593-contract branch October 29, 2026 08:02
@sourcery-ai

sourcery-ai Bot commented Oct 29, 2026

Copy link
Copy Markdown

Sorry @maiphucgiang, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 8 hours and 5 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 29, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR updates domestic WorkBuddy support to the 5.9.3 client contract by revising profile and identity headers, introducing stable UUIDv7 session and per-attempt tracing metadata, and adding endpoint-scoped deterministic gzip serialization with preview decoding. Existing CLI and international behavior remains profile-specific, while growth fingerprints, documentation, and request fixtures/tests are updated for the new wire contract.

Sequence diagram for profile-aware WorkBuddy chat requests

sequenceDiagram
    participant Client
    participant RequestContext
    participant UpstreamIO
    participant WorkBuddy

    Client->>RequestContext: session_conversation_id(profile, account, session_key)
    RequestContext-->>Client: UUIDv7 conversation ID for cn-work
    Client->>RequestContext: build_attempt_headers(conversation_id)
    RequestContext-->>Client: X-Session-ID, tracing headers, baggage, ACP ID
    Client->>UpstreamIO: open_backend_stream(url, headers, body)
    UpstreamIO->>UpstreamIO: _json_request_kwargs(headers, body, url)
    alt cn-work chat body is at least 1024 bytes
        UpstreamIO->>WorkBuddy: POST gzip JSON with per-attempt headers
    else CLI or international WorkBuddy chat
        UpstreamIO->>WorkBuddy: POST gzip JSON with profile headers
    else uncompressed chat or non-chat endpoint
        UpstreamIO->>WorkBuddy: POST JSON with original transport
    end
    WorkBuddy-->>Client: Streaming chat response
Loading

File-Level Changes

Change Details Files
Aligned client identity, authentication metadata, and account-scoped headers with the domestic WorkBuddy 5.9.3 contract while preserving CLI and international variants.
  • Bumped domestic WorkBuddy and growth-client version fingerprints to 5.9.3.
  • Added enterprise-aware private-data headers and sanitized JWT/account identity metadata.
  • Added domestic WorkBuddy-specific request IDs and adjusted refresh, catalog, and check-in headers.
  • Marked automated chat and rate-probe calls as auxiliary local-agent traffic.
app/client_profiles.py
app/credits.py
app/buddy_task.py
app/rate_measurement.py
app/growth_events.py
converter.py
docs/advanced.md
docs/advanced.zh-CN.md
tests/test_identity_sync.py
tests/test_credits.py
tests/test_buddy_task.py
tests/test_model_rates.py
tests/test_growth_chains.py
tests/test_catalog.py
tests/test_upstream_compat.py
Implemented domestic WorkBuddy session, attempt tracing, ACP, baggage, and request-ID relationships using stable UUIDv7-shaped identifiers.
  • Derived stable session conversation IDs from profile, account, and session key.
  • Generated per-attempt message/request/trace identifiers while keeping session and ACP identifiers stable.
  • Added domestic runtime, session, ACP connection, root request, and baggage headers.
  • Kept existing identity and tracing relationships for CLI and international profiles.
app/request_context.py
converter.py
tests/test_request_context.py
Added profile- and endpoint-aware replay-safe gzip serialization for official chat traffic.
  • Compressed all CLI and international WorkBuddy chat JSON and domestic WorkBuddy bodies at or above 1024 bytes.
  • Restricted compression to official chat completion paths and preserved media, search, fetch, and other transport behavior.
  • Made retries reuse identical serialized bytes and taught the preview server to decode gzip requests.
app/upstream_io.py
preview/upstream.py
tests/test_upstream_io.py
tests/test_preview.py
tests/test_region_routing.py
tests/test_chat_input.py
tests/test_dsml.py
tests/test_message_normalization.py
tests/test_nonstream_disconnect.py
tests/test_reasoning_requests.py
tests/test_server_tools.py
tests/test_stream_failover.py
tests/test_api_flow.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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