Annotate the actions that declare an outputSchema as PageResult - #14
Merged
Merged
Conversation
The eight tools that answer with structuredContent (goto and the actions) now say so on tools/list with an outputSchema, and `Session.call` already returns a `PageResult` for exactly those answers. The generator reads that schema, so their methods are annotated `-> PageResult` instead of `Any` without a hand-maintained list. `Browser.tools` carries it as `output_schema`. `PageResult` is imported under TYPE_CHECKING, since browser.py imports the generated module; pdoc still resolves and links it. Also picks up nightly's new `goto` description. Part of #6.
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.
Item 1 of #6, as far as the wire allows.
lightpanda-io/browser#3694 gave
goto,click,fill,scroll,hover,press,selectOptionandsetCheckedastructuredContentanswer, declared by anoutputSchemaontools/list, andSession.callalready turns that answer into aPageResult(#12).generate_methods.pynow reads the schema, so those sixteen methods (sync and async) are annotated-> PageResultinstead of-> Any. Nothing in the generator names the eight tools: a tool that gains or drops anoutputSchemachanges its annotation on the next regeneration, which CI already enforces.Browser.toolskeeps the schema asoutput_schema(None when a tool declares none), which is where the generator reads it.PageResultis imported underTYPE_CHECKINGin the generated module, becausebrowser.pyimports_methods.pyand a runtime import would be circular. pdoc evaluates that block: the rendered page links all sixteen return annotations toPageResult.The regeneration also picks up nightly's reworded
gotodescription (it now points at the HTTP status), whichmainwould need anyway to pass the drift check.Still
AnyThe data tools (
tree,links,extract, …) return JSON as text, and MCP carries no shape for that unless the tool declares anoutputSchema, which #3694 deliberately left off them (it would oblige astructuredContentcopy of a payload that can run to tens of KB, and arrays would need a wrapper). Narrowing those would mean a hand-written map in the generator, which is what this approach avoids. Several of their descriptions already state the shape in prose, and that prose is in the docstrings.