Repository navigation
Agent package, slice 5: AsAgentTools - #110
Merged
Merged
Conversation
IGraphClientSource<TSelf> is implemented by every generated client: its GraphClient and WithRequestConfiguration. Other packages can then work with any generated client generically, for example to derive a per-user client of the same type, without reflection. It is additive; the generated client interface is unchanged. The test clients are regenerated. GetRequest() on typed queries builds the request without contacting the server: safe mode's schema check is skipped. It is meant for showing or logging a query.
Fifth slice of the agent package (docs/design/agent-mode.md). AsAgentTools on a client generated with --agent (or with SDL passed explicitly) returns graphql_query, describe_operation, describe_type and search_schema as AIFunctions; graphql_query carries the Index in its description. - AccessToken derives a per-user client, so every query the agent causes, raw or typed, carries the user's token. - OnQuery sees every query, sent or rejected, with validation errors, server errors and duration; a failing logger does not break the agent's call. - Example adds a common task written with the typed client. Examples are validated against the scope at setup, listed in the Index, shown in full in describe_operation and found by search_schema. Before the agent sees them, variables lose the client's uniqueness suffixes where unambiguous and the query is printed on one line. Adds Microsoft.Extensions.AI.Abstractions 10.10.0 to the AI package only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fifth slice of the agent package described in docs/design/agent-mode.md: the public entry point that turns a generated client into agent tools.
Changes
Client and generator
IGraphClientSource<TSelf>, implemented by every generated client: itsGraphClientandWithRequestConfiguration.AsAgentTools<TClient>uses it to execute through the client and derive a per-user client of the same type without reflection. Additive: the generated client interface is unchanged. Test clients regenerated (one line each).GetRequest()on typed queries: the request built without contacting the server (safe mode's schema check skipped), used to render examples at setup.Linq2GraphQL.Client.AIAsAgentToolsreturnsgraphql_query,describe_operation,describe_typeandsearch_schemaas Microsoft.Extensions.AIAIFunctions, with parameter descriptions;graphql_querycarries the Index in its description. It requires a client generated with--agent; an overload takes the SDL explicitly.o.AccessToken: a per-user client viaWithAccessToken, so every query the agent causes, raw or typed, carries the user's token.o.OnQuery: every query, sent or rejected, with validation errors, server errors and duration. A failing logger does not break the agent's call.o.Example(...)with typed queries: validated against the scope at setup, listed in the Index, shown in full indescribe_operationfor the operations they use, found bysearch_schema. Tidied before the agent sees them:query($name_1_1: String ){ hello(name:$name_1_1 ) }becomesquery($name: String) { hello(name: $name) }.Microsoft.Extensions.AI.Abstractions10.10.0, in the AI package only.Design doc: slice status,
IGraphClientSource,GetRequest()and example tidying.Testing
AgentToolsExtensionsTestscalls the tools throughAIFunction.InvokeAsync, as an agent framework does: the four tools and their descriptions, queries with variables, describe and search, the bearer token reaching the server,OnQueryfor sent and rejected queries, examples in all three places, an example outside the scope failing at setup, the explicit-SDL overload.ExampleFormatterTests: variable renaming, keeping suffixes when plain names would clash, string literals left alone, one-line printing../scripts/regenerate-test-clients.ps1 -Checkis covered by CI; locked restore succeeds.