Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3db2c5559d
ℹ️ 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".
| url=target_url, | ||
| data=task.instance_body, | ||
| use_chunked=use_chunked, | ||
| extra_headers=extra_headers, |
There was a problem hiding this comment.
Accept propagated headers in the cancellation test stub
The new keyword makes both cases of test_real_ready_worker_cancellation_paths fail because its monkeypatched fake_forward_request in test/observability/test_scheduler_proxy_production_paths.py still accepts only url, data, and use_chunked. Once the ready worker reaches this call, Python raises TypeError before the test can cancel the simulated downstream operation, so the request is finalized as failed rather than cancelled and the assertions at lines 304–305 fail; update that stub to accept extra_headers as the other forwarding stubs now do.
Useful? React with 👍 / 👎.
| yield chunk | ||
| except asyncio.CancelledError: |
There was a problem hiding this comment.
Finalize traces when streaming iterators are closed
When a streaming consumer stops early and closes this async generator—for example, after a client disconnect causes the response body iterator to be closed—Python injects GeneratorExit, which is handled by neither CancelledError nor Exception. Calling aclose() after the first yielded chunk therefore bypasses both the cancellation finalization and the success block, leaving completion/decode stages running and session.request_trace unset; handle generator closure as cancellation so these research timing stages are always finalized.
AGENTS.md reference: AGENTS.md:L203-L212
Useful? React with 👍 / 👎.
Motivation
Description
proxy/queue/manager.pynow encodes the taskTraceContextwithencode_trace_headers()and passes a fresh mapping of the exact reserved headers through the existingforward_request(..., extra_headers=...)seam without mutatingtask.instance_bodyor forwarding arbitrary incoming headers.instance/instance_api.pyresolvesCACHEROUTE_RUNTIME_PROFILEandCACHEROUTE_TRACE_SAMPLE_RATEonce at FastAPI lifespan startup (immutable app.state), and wraps downstream calls with Instance-local collection using a new helper.instance/observability.pywhich implementsresolve_instance_context(),start_instance_trace_session(),collect_non_streaming()andcollect_streaming()to validate/accept propagated contexts, perform safe local fallback context creation, create a request-localTraceCollectoronly when sampled, and record Instance-provenance stages.TraceComponent.INSTANCEwith the existingTraceStageNameenum values:COMPLETION(starts before downstream call, finishes on success/failure/cancel),FIRST_TOKEN(starts at downstream invocation, finishes at first non-empty chunk), andDECODE(starts after first non-empty chunk, finishes at stream end); non-streaming requests skipFIRST_TOKEN/DECODEwith stable reasons; parent relationships and deterministic ordering are preserved.doc/architecture/observability-v1.md,doc/research/issue-141-unified-observability.md, and handbook chaptersdoc/developer-handbook/runtime-flows.mdanddoc/developer-handbook/configuration-and-interfaces.mdto record the exact trust/overwrite boundary and Instance startup resolution rules.test/observability/test_instance_observability.pyand updatedtest/observability/test_scheduler_proxy_production_paths.pyand repository-governance tests to accept the canonical encode/forward pattern.Changed files (complete list):
Exact Proxy->Instance reserved header vocabulary forwarded (unchanged):
scheduler-request-idx-cacheroute-trace-versionx-cacheroute-trace-idx-cacheroute-runtime-profilex-cacheroute-trace-sampledx-cacheroute-trace-created-atConfirmations and invariants:
x-cacheroute-*headers or W3C Trace Context).Handbook impact
Testing
f4e19b40416372599a57af01ea14ec5e29af4867and base/main SHA used in this checkout:28e857c52a7a45a9c6c971be96ec32a4059dad7f.python3 -m compileall -q src test scheduler proxy instance— PASSED.python3 -m pytest -q test/test_repository_governance.py— PASSED (14 tests).python3 -m pytest -q test/test_documentation_governance.py— PASSED (12 tests).python3 -m pytest -q test/observabilityattempted but the environment lacked runtime test dependencies (notablypydanticandnumpy), causing collection errors; these tests are ENVIRONMENT-BLOCKED in this execution.pytestmodules that importpydantic,numpy,fastapior require build tooling;python3 -m build --no-isolationand wheel build/installation were not completed due to missingbuild/setuptools.build_meta.compileall(src/test/scheduler/proxy/instance),test/test_repository_governance.py(14 passed),test/test_documentation_governance.py(12 passed), targeted repository-governance assertions adjusted and validated.test/observabilitycollection/run (missingpydantic/numpy),test/test_namespace_layout.pyand other contract/wheel tests that requirepydantic,numpy,fastapi, or packaging tooling, andpython3 -m build(missingbuildmodule / setuptools backend in this environment).Known limitations and next steps
pydantic,numpy,fastapi, build toolchain) and produce the full validation results and wheel artifacts requested by Issue v0.1.10-4C: propagate internal trace context from Proxy to Instance and instrument Instance-observed vLLM transport stages #185; those steps were blocked here by the execution environment.Closes #185
Refs #137, #141, #142, #157, #159, #178, #179, #182, #183, #180, #184, #139, #140
Codex Task