Skip to content

Add discovery API to Python SDK#39

Closed
jadenfix wants to merge 4 commits into
mainfrom
codex/discovery-python-sdk
Closed

Add discovery API to Python SDK#39
jadenfix wants to merge 4 commits into
mainfrom
codex/discovery-python-sdk

Conversation

@jadenfix
Copy link
Copy Markdown
Member

Summary

  • bump roe-ai to 1.0.802
  • regenerate the SDK OpenAPI client from the discovery-enabled roe-main SDK spec
  • add client.discovery.list_agent_engine_types()
  • add client.discovery.list_supported_models(capability=None)
  • keep the 1.0.801 Retry-After/header behavior from main

Testing

  • uv run ruff check src/roe/api/discovery.py src/roe/api/__init__.py src/roe/client.py tests/unit/test_discovery.py
  • uv run pytest tests/unit -q

Dependency

jadenfix and others added 2 commits May 19, 2026 13:52
Resync openapi.yml + generated client with the latest roe-main PR 3232
state (commits 1e84e190f rename + 4e3b70241 trim). Two contract changes
land here:

- `/v1/discovery/{agent-engine-types,supported-models}/` → `/v1/agents/{types,models}/`
- `engines` items are now an open dict (six fields: class_id, display_name,
  description, summary, input_schema, default_values), not TemporalWorkflow

The old `TemporalWorkflow.from_dict` popped `form_type`, which the new
payload omits — `list_agent_engine_types()` against current backend
would have raised `KeyError`. Adds a from_dict test against a realistic
six-field engine response to catch this category of drift in CI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jadenfix
Copy link
Copy Markdown
Member Author

@greptile review

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 20, 2026

Greptile Summary

This PR adds a discovery namespace to the Python SDK, exposing two new tenant-agnostic endpoints (GET /v1/agents/types/ and GET /v1/agents/models/) that let callers enumerate valid engine types and supported LLM models before creating agents. The version is bumped to 1.0.802 and the OpenAPI spec is regenerated to include the new schemas.

  • DiscoveryAPI wraps both generated endpoints, correctly translates None→UNSET for the optional capability filter, and delegates error translation to the shared translate_response helper.
  • Generated models (AgentEngineTypeList, SupportedLLMModel, SupportedLLMModelList, AgentEngineTypeListEnginesItem) follow the existing attrs-based pattern; engines items are typed as free-form additionalProperties dicts, matching the open-ended OpenAPI schema.
  • Unit tests cover both endpoints, the None→UNSET path, error propagation, and round-trip deserialization of realistic backend payloads.

Confidence Score: 5/5

Safe to merge; the new discovery endpoints are additive, tenant-agnostic, and do not touch existing auth or agent creation paths.

The handwritten wrapper (DiscoveryAPI) is straightforward and well-tested. The generated files are self-contained additions with no changes to existing behaviour. All findings are cosmetic or stylistic and do not affect runtime correctness.

Generated model files (agent_engine_type_list.py, supported_llm_model.py, etc.) carry unused imports from the code-generator template that will trip linters if ruff is ever extended to cover _generated/.

Important Files Changed

Filename Overview
src/roe/api/discovery.py New DiscoveryAPI class wrapping both generated endpoints; correctly translates None→UNSET for capability, calls translate_response, and guards against null parsed responses.
src/roe/client.py Added discovery property and DiscoveryAPI instantiation; correctly passes only raw_client (no config) consistent with tenant-agnostic design.
tests/unit/test_discovery.py Thorough unit tests covering both endpoints, capability filter translation, error propagation, and deserialization; a review-tool annotation comment was accidentally committed on line 1218.
src/roe/_generated/api/discovery/discovery_supported_models_list.py Generated endpoint for /v1/agents/models/; capability param correctly filtered via UNSET sentinel; misaligned indentation on capability= arg in sync/asyncio helpers is cosmetic but notable.
src/roe/_generated/api/discovery/discovery_agent_engine_types_list.py Generated endpoint for /v1/agents/types/; straightforward GET with no params; functions correctly.
src/roe/_generated/models/agent_engine_type_list.py Generated model for AgentEngineTypeList; correct deserialization; unused BinaryIO/TextIO/Generator imports and duplicate cast import are generation artifacts.
src/roe/_generated/models/supported_llm_model.py Generated model for SupportedLLMModel; all 10 required schema fields are present and deserialized correctly; same unused import pattern as other model files.
openapi/openapi.yml Added two new discovery paths and three new schemas; schemas correctly mark all required fields; no authentication blocks declared (tenant-agnostic by design).

Sequence Diagram

sequenceDiagram
    participant Caller
    participant RoeClient
    participant DiscoveryAPI
    participant GeneratedEndpoint
    participant Server

    Caller->>RoeClient: client.discovery.list_agent_engine_types()
    RoeClient->>DiscoveryAPI: list_agent_engine_types()
    DiscoveryAPI->>GeneratedEndpoint: "sync_detailed(client=raw_client)"
    GeneratedEndpoint->>Server: GET /v1/agents/types/
    Server-->>GeneratedEndpoint: 200 AgentEngineTypeList JSON
    GeneratedEndpoint-->>DiscoveryAPI: Response[AgentEngineTypeList]
    DiscoveryAPI->>DiscoveryAPI: translate_response(response)
    DiscoveryAPI-->>Caller: AgentEngineTypeList

    Caller->>RoeClient: "client.discovery.list_supported_models(capability=image)"
    RoeClient->>DiscoveryAPI: "list_supported_models(capability=image)"
    Note over DiscoveryAPI: None to UNSET translation applied
    DiscoveryAPI->>GeneratedEndpoint: "sync_detailed(client=raw_client, capability=image)"
    GeneratedEndpoint->>Server: "GET /v1/agents/models/?capability=image"
    Server-->>GeneratedEndpoint: 200 SupportedLLMModelList JSON
    GeneratedEndpoint-->>DiscoveryAPI: Response[SupportedLLMModelList]
    DiscoveryAPI->>DiscoveryAPI: translate_response(response)
    DiscoveryAPI-->>Caller: SupportedLLMModelList
Loading

Fix All in Claude Code

Reviews (2): Last reviewed commit: "fix: drop unused RoeConfig from Discover..." | Re-trigger Greptile

Comment thread src/roe/api/discovery.py Outdated
Comment thread src/roe/_generated/api/discovery/discovery_supported_models_list.py
Discovery endpoints are tenant-agnostic; carrying RoeConfig on the API
class was a dead public surface that misled future readers. Also remove
the duplicate cast/UNSET and unused quote imports from the regenerated
endpoint modules, and add a regression test for the capability=None to
UNSET translation path.

Greptile P2 review id 33087814.
@jadenfix
Copy link
Copy Markdown
Member Author

@greptile review

CI's check-codegen-drift job re-runs codegen and rejects any drift from
the committed generated files. The duplicate cast/UNSET and unused quote
imports are codegen-tool quirks; cleaning them by hand made the
committed tree differ from regen output and broke CI. Restore the
files. The codegen-side fix is tracked separately and is not in scope
for this PR.
@jadenfix
Copy link
Copy Markdown
Member Author

Closing per request.

@jadenfix jadenfix closed this May 26, 2026
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