[train] Gateway anthropic adapter#70
Conversation
… stop param, drop tool_call id from prefix comparison
There was a problem hiding this comment.
Code Review
This pull request introduces provider adapters for Anthropic and OpenAI to translate wire protocol requests into a canonical internal format (InternalGenerationRequest), decoupling wire translation from the session and codec logic. It also adds a standalone gateway debug launcher (debug_launcher.py) with extensive documentation and comprehensive unit tests. Feedback on the debug launcher suggests simplifying the redundant type checking and decoding logic for TimeoutExpired exceptions since subprocess.run is invoked with text=True.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| stdout = exc.stdout if exc.stdout is not None else exc.output | ||
| stderr = exc.stderr | ||
| if isinstance(stdout, bytes): | ||
| stdout = stdout.decode(errors="replace") | ||
| elif stdout is None: | ||
| stdout = "" | ||
| else: | ||
| stdout = str(stdout) | ||
| if isinstance(stderr, bytes): | ||
| stderr = stderr.decode(errors="replace") | ||
| elif stderr is None: | ||
| stderr = "" | ||
| else: | ||
| stderr = str(stderr) |
There was a problem hiding this comment.
The subprocess.run call uses text=True, so exc.stdout and exc.stderr from a TimeoutExpired exception will be strings or None. The complex type checking and decoding logic for these attributes can be simplified.
Additionally, exc.output is an alias for exc.stdout, making the conditional assignment on line 450 redundant.
| stdout = exc.stdout if exc.stdout is not None else exc.output | |
| stderr = exc.stderr | |
| if isinstance(stdout, bytes): | |
| stdout = stdout.decode(errors="replace") | |
| elif stdout is None: | |
| stdout = "" | |
| else: | |
| stdout = str(stdout) | |
| if isinstance(stderr, bytes): | |
| stderr = stderr.decode(errors="replace") | |
| elif stderr is None: | |
| stderr = "" | |
| else: | |
| stderr = str(stderr) | |
| stdout = exc.stdout or "" | |
| stderr = exc.stderr or "" |
Summary
examples/gateway/debug_launcher.pyplus docs and tests for local gateway debugging and trajectory collection.Testing
pytest -q tests/uni_agent/gateway/test_debug_launcher.py tests/uni_agent/gateway/adapters/test_openai_adapter.py tests/uni_agent/gateway/adapters/test_anthropic_adapter.py tests/uni_agent/gateway/test_gateway_actor_on_cpu.py