Repository navigation
Add the domain tools to the Python toolkit - #76
josephfeleke wants to merge 2 commits into
Conversation
list_domains, get_domain, create_domain, get_domain_setup_link and verify_domain, with the same descriptions as the Node toolkit, using the Python field names.
| return next(t for t in tools if t.name == name) | ||
|
|
||
|
|
||
| def test_domain_tools_sit_after_delete_inbox_and_before_the_thread_tools(): |
There was a problem hiding this comment.
Brittle position test (nit). This pins the exact span between delete_inbox and list_threads, so any tool inserted there later fails the test without a defect. Suggest asserting the five names are present and contiguous.
There was a problem hiding this comment.
Keeping the exact span. The order is what the model sees, and this test is what keeps the Python order the same as Node, where tests/domains.test.ts pins the same span. A tool added there later should update both on purpose.
| assert "HTTP 422" in str(raised.value) | ||
|
|
||
|
|
||
| def test_langchain_create_domain_passes_the_flags_through(): |
There was a problem hiding this comment.
LangChain nulls not pinned (nit). LangChain fills omitted optional fields with None, so the flags the model left out reach the API as null. That is safe only because the API reads a create-body null as unset. The OpenAI test pins this, the LangChain one does not. Suggest asserting the non-null part of the body is exactly what the model set.
There was a problem hiding this comment.
Fixed in bf41c5d: the test now asserts that the non-null part of the body is exactly {domain, subdomains_enabled}, as the OpenAI test does.
| ThreadIdField = Annotated[str, Field(description="ID of thread")] | ||
| MessageIdField = Annotated[str, Field(description="ID of message")] | ||
| AttachmentIdField = Annotated[str, Field(description="ID of attachment")] | ||
| DomainIdField = Annotated[str, Field(description="ID of domain (from list_domains or create_domain)")] |
There was a problem hiding this comment.
Field description (nit). get_domain also returns the ID, not only list_domains and create_domain.
There was a problem hiding this comment.
Leaving as is. The description names where an agent gets an ID it does not have yet. Calling get_domain already needs the ID, so it is not a source.
| func=delete_inbox, | ||
| ), | ||
| Tool( | ||
| name="list_domains", |
There was a problem hiding this comment.
Observation, not a defect. list_domains uses ListItemsParams, so the SDK's ascending is not exposed. That matches list_inboxes.
There was a problem hiding this comment.
Agreed, a deliberate match with list_inboxes. No change.
… setup and verify guidance create_domain no longer offers allow_conflicting_provider, and parses its arguments so the OpenAI and LiveKit adapters, which pass raw arguments, cannot send it either. The setup link and verify_domain descriptions match the Node wording. The LangChain create test now checks that only the flags the model set carry a value.
Why
The Python toolkit should offer the same domain tools as the Node toolkit, so an agent built on the OpenAI Agents SDK, LangChain or LiveKit can set up a custom domain over the API too.
What
list_domains,get_domain,create_domain,get_domain_setup_linkandverify_domain, placed afterdelete_inboxas in Node.conflicting_provider,provider_name).create_domaindoes not offerallow_conflicting_provider, for the reason given in Add create_domain #74. It parses its arguments, so the OpenAI and LiveKit adapters, which pass raw arguments, cannot send it either.verify_domainreturnsNone, which the adapters turn into"OK".nullfor the flags it leaves unset. The SDK sends those asnull, and the API reads anullin a create body as unset (asInputSchema), so the API defaults still apply.Test
uv run pytest(68 passed).tests/test_domains.pyruns the real Python SDK overhttpx.MockTransport, so a wrong method or keyword name fails the way it would against the API:falseflags;allow_conflicting_provideris never sent; a create without a domain makes no requestnull(no flag gets a value the model did not choose), the setup link URL,"OK"for verify, and the 422 conflict raised with the provider namedToolErrorget_domainuntilVERIFIEDEach rule was broken on purpose and confirmed to fail at least one test: raw arguments passed to the SDK,
falseflags dropped, the stop condition removed, verify and the setup link callingget, the page token dropped, a camelCase field in a description, the wrong permission named, and a flag made required.