docs(think): move developer content out of the LLM-facing docstring (#320) - #549
Open
Ashutosh0x wants to merge 1 commit into
Open
docs(think): move developer content out of the LLM-facing docstring (#320)#549Ashutosh0x wants to merge 1 commit into
Ashutosh0x wants to merge 1 commit into
Conversation
The @tool docstring becomes the tool_spec description sent to the model on every request. think's docstring carried Python usage examples, environment variable documentation, internal "How It Works" steps and developer notes, all of which reached the LLM. Move that content to the module docstring, matching the pattern shell.py already uses, and keep the @tool docstring focused on what the model needs to decide whether and how to call the tool. No code or behavior changes; all eight parameters remain documented, so inputSchema is unaffected. tool_spec description: 6017 -> 598 characters. Refs strands-agents#320.
Ashutosh0x
requested review from
Unshure and
Copilot
and removed request for
Copilot
July 29, 2026 03:25
Ashutosh0x
requested a deployment
to
manual-approval
July 29, 2026 03:25 — with
GitHub Actions
Waiting
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.
Addresses task 1 of #320 (@notowen333: "Clean up doc strings in community tools ... Task 1 is eligible for community contribution"), starting with the
thinktool that @jsgsamzn used as the reproducer.Problem
ToolSpec.descriptionis built by_extract_description_from_docstring(strands-py/src/strands/tools/decorator.py), which strips only theArgsblock - its own docstring says it preserves "Returns, Raises, Examples, and other sections". So Python usage examples,STRANDS_*environment variable docs, internal "How It Works" steps and developer notes all ship to the model on every request.Measured on
mainby replicating that function against the current sources:thinkswarmgraphshellshellis the outlier because it already does the right thing - developer usage lives in the module docstring, and the@tooldocstring is written for the model. That is Solution 1 from the issue, and this PR applies it tothink.Change
Purely a docstring reorganisation in
src/strands_tools/think.py:STRANDS_*configuration block, and the developer notes. Nothing is deleted; it moves to where a developer reading the source will still find it.@tooldocstring - what the tool does, when a model should reach for it, the recursion constraint, all eightArgs, andReturns.Result: tool_spec description 6,017 -> 598 characters (-90%), with no Python examples and no environment variables left in it.
Parameter descriptions are unaffected. They are parsed separately into
inputSchemaviaparam_descriptions, so the model keeps full per-argument documentation - this only removes the prose the model was never meant to read.While moving it I also fixed a broken snippet: the old
thinking_system_prompt=Use Socratic questioning method:example was missing its quotes.Validation
ast.parsecleaninputSchemais byte-identical)_extract_description_from_docstringexactlytests/test_think.pyhas nodescription/tool_spec/__doc__references)I could not install
strands-agentsin my environment to render the realtool_spec, so the figures above come from replicating the extraction function rather than executing the decorator. Worth a sanity check in review, though the parity check on the signature meansinputSchemacannot have shifted.Scope
Deliberately one tool.
swarmandgraphhave the same problem and I am happy to extend this PR to both, but the exact voice of an LLM-facing docstring is a judgement call and it seemed better to agree the shape on one tool first than to send three at once. Say the word and I will add them.