Skip to content

Agent package, slice 4: the four tools as plain methods - #109

Merged
joadan merged 1 commit into
mainfrom
agent-ai-tools
Oct 15, 2026
Merged

joadan merged 1 commit into
mainfrom
agent-ai-tools

Conversation

@joadan

@joadan joadan commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Fourth slice of the agent package described in docs/design/agent-mode.md: the four agent tools as plain methods, with no AI framework dependency. The adapter in slice 5 wraps them as AIFunctions.

Changes

AgentToolset (internal)

  • Index: the rendered Index, for the graphql_query tool description.
  • QueryAsync (graphql_query): validates the query and its variables and only sends a valid query, through GraphClient.ExecuteAsync so per-user tokens apply. Returns JSON with data and errors; validationErrors with a note that nothing was sent; or requestError for transport failures.
  • DescribeOperations (describe_operation): description, arguments with defaults, descriptions and filter and sort summaries, the return type in outline, and a starter query. Unknown names get a "did you mean".
  • DescribeTypes (describe_type): full detail per type in request order, plus related types in outline. Filter and sort inputs get their summary line; connection types point to their node type.
  • Search (search_schema): operations, types, fields and enum values. Exact names first, then prefixes, substrings and descriptions; ties by kind (operation, type, field, value); at most 20 results.

Starter queries: required arguments become variables and the first plain fields are selected. Paged operations get no page size: the first version added first: 10, which the test server rejected because orders has a maximum page size of 2. The schema does not publish that maximum, so the server's default is used instead.

Refactors: the "did you mean" logic moves from the validator to a shared NameSuggestions helper; renderer helpers are internal and the filter and sort summary lines reusable.

Design doc: slice status and the starter-query rule.

Testing

  • 280 tests pass, 13 new (AgentToolsetTests):
    • graphql_query against the test server: data, variables, validation errors with a check that nothing was sent, server errors.
    • Snapshots of describe_operation and describe_type output.
    • The starter query of every query in the test schema passes the validator and runs on the server.
    • Search ranking and the no-match message.

Fourth slice of the agent package (docs/design/agent-mode.md). AgentToolset
holds the tools without any AI framework dependency; the adapter in the next
slice wraps them:

- graphql_query validates the query and its variables and only sends a valid
  one. It returns data and errors as JSON, validationErrors with a note that
  nothing was sent, or requestError for transport failures.
- describe_operation returns each operation's description, arguments with
  defaults and filter and sort summaries, the return type in outline, and a
  starter query.
- describe_type returns full detail for types, in request order, with related
  types in outline; filter and sort inputs get their summary line.
- search_schema matches operations, types, fields and enum values, names
  before descriptions, ties by kind, at most 20 results.

Starter queries make required arguments variables and select the first plain
fields. Paged operations get no page size, because the schema does not publish
the server's maximum; every starter query is checked against the test server.

The "did you mean" logic moves to a shared NameSuggestions helper, and the
renderer's filter and sort summary lines become reusable.
@joadan
joadan merged commit 516d4cb into main Oct 15, 2026
2 checks passed
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