Conversation
| ExampleCheck( | ||
| name="Claude Code gateway invocation is documented without executing it", | ||
| passed=( | ||
| "ANTHROPIC_BASE_URL" in claude_gateway_command | ||
| and "ANTHROPIC_API_KEY" in claude_gateway_command | ||
| and "claude --model" in claude_gateway_command | ||
| ), | ||
| details=claude_gateway_command, | ||
| ), |
There was a problem hiding this comment.
low value check: strings are hardcoded om build_claude_gateway_command()
| agent_id, reused_agent = await ensure_claude_code_agent(sdk) | ||
| resources_created.append(f"agent:{agent_id}:reused" if reused_agent else f"agent:{agent_id}") |
There was a problem hiding this comment.
do we need to add a cleanup() call for the agent?
| - Upload a temporary bootstrap directory as a storage object with a TTL | ||
| - Launch a devbox with agent, code, and object mounts together | ||
| - Verify the gateway token and URL are present instead of the raw Anthropic key | ||
| - Run Claude Code through the Anthropic agent gateway |
There was a problem hiding this comment.
should we clarify that we build the command but don't actually execute it?
| resources_created.append(f"secret:{secret.name}") | ||
| cleanup.add(f"secret:{secret.name}", secret.delete) | ||
|
|
||
| bootstrap_dir = create_bootstrap_dir() |
There was a problem hiding this comment.
why not use with tempfile.TemporaryDirectory() like in blueprint_with_build_context.py? feels more pythonic
| async def ensure_claude_code_agent(sdk: AsyncRunloopSDK) -> tuple[str, bool]: | ||
| """Return a reusable Claude Code agent, creating it if needed.""" | ||
| existing_agents = await sdk.agent.list(name=CLAUDE_CODE_AGENT_NAME, limit=20) | ||
| existing_infos = await asyncio.gather(*(agent.get_info() for agent in existing_agents)) | ||
|
|
||
| matching_agents = sorted( | ||
| ( | ||
| info | ||
| for info in existing_infos | ||
| if info.name == CLAUDE_CODE_AGENT_NAME | ||
| and info.version == CLAUDE_CODE_AGENT_VERSION | ||
| and info.source is not None | ||
| and info.source.type == "npm" | ||
| and info.source.npm is not None | ||
| and info.source.npm.package_name == CLAUDE_CODE_PACKAGE | ||
| ), | ||
| key=lambda info: info.create_time_ms, | ||
| reverse=True, | ||
| ) | ||
| if matching_agents: | ||
| return matching_agents[0].id, True | ||
|
|
||
| agent = await sdk.agent.create_from_npm( | ||
| name=CLAUDE_CODE_AGENT_NAME, | ||
| version=CLAUDE_CODE_AGENT_VERSION, | ||
| package_name=CLAUDE_CODE_PACKAGE, | ||
| ) | ||
| return agent.id, False |
There was a problem hiding this comment.
feels like too much boilerplate for an example. we should just create a new agent and clean it up to more cleanly demonstrate the happy path
| "if [ -d /home/user/rl-cli ]; then printf /home/user/rl-cli; " | ||
| "elif [ -d /home/user/rl-clis ]; then printf /home/user/rl-clis; " |
There was a problem hiding this comment.
why are there two possibilities?
| f'ANTHROPIC_API_KEY="${GATEWAY_ENV_PREFIX}" ' | ||
| f"claude --model {shlex.quote(CLAUDE_MODEL)} " | ||
| f"-p {shlex.quote(CLAUDE_PROMPT)} " | ||
| "--dangerously-skip-permissions" |
There was a problem hiding this comment.
what is this flag? feels suspect to use a "dangerous" flag as part of our example code: agents might read this as the recommended pattern
Shows off how to use our main types of mounts with the usage patterns we expect: