docs: improve agent guidance#2959
Draft
opieter-aws wants to merge 1 commit into
Draft
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
94bf130 to
6be27c3
Compare
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.
Description
The
AGENTS.mdfiles are supposed to steer coding agents toward house conventions, but an audit of both SDKs against their own guidance turned up three gaps that let agents drift: the highest-traffic patterns weren't documented at all, several rules lived only in side docs an agent readingAGENTS.mdnever opens, and one cross-SDK rule was actively wrong.This change makes the guidance match what the code already does and surfaces the un-lintable rules where an agent will actually load them. It is documentation-only — no source or behavior changes.
The most-repeated patterns are now written down. Adding a model provider and the async-generator streaming contract are the two patterns a contributor copies most often, and neither appeared in either
AGENTS.md. Both SDKs now have mirrored "Adding a Model Provider" and "Async & Streaming" sections built from the existing skeleton (config-as-TypedDict/interface,validate_config_keys/resolveConfigMetadata, the keyword-only*beforetool_choice, vendor-error translation), plus a Python "Data Structures" rule (TypedDictfor wire/config shapes,@dataclassfor runtime objects, pydantic only for model-read/write schemas) and a TypeScriptinterface-vs-typerule.Un-lintable rules are surfaced where they're needed. Several judgment rules lived only in
docs/STYLE_GUIDE.md/docs/HOOKS.mdand were referenced only as bottom-of-page links. The Python guide now gates those reads at the point of use ("before adding a public interface, read STYLE_GUIDE.md"; "before adding a hook event, read HOOKS.md") and inlines the rules a linter can't catch (Protocol-over-Callable,tool_nameover hardcoded strings,X | NoneoverOptional, scoped# type: ignore[code], typed exceptions over bareException).Genuinely shared rules now live in one place. Plugin naming, cross-SDK literal parity, public/internal API marking, the logging format, evergreen comments, and directory-naming parity were documented only on the TypeScript side though they apply to both SDKs — they're now a single "Cross-SDK Conventions" section in the root
AGENTS.mdthat both sub-guides reference, so they can't drift apart.Two contradictions fixed. The TypeScript guide told agents both "always provide explicit return types" and "leverage type inference where appropriate" with no precedence — now scoped to "explicit on signatures, infer locals." And the "use exactly the same literal as the Python SDK" rule was false for multi-word values (Python
tool_use→ TStoolUsevia an explicit map); the rule now states the real convention (single-word identical, multi-word camelCased in TS, wire names verbatim).strands-ts/docs/TESTING.mdalso referenced atests_integ/directory that doesn't exist — corrected totest/integ/.New
strands-py/docs/TESTING.md. The TypeScript SDK had a 738-line testing guide; Python had ~40 lines inAGENTS.mdand nodocs/TESTING.md, which hid a real shared-fixtures library agents were reinventing. The new file documents the fixtures quick-reference, thetru_/exp_assertion-pair naming, whole-object assertions, and the strict-asyncio marker rule.Related Issues
None — maintenance change from a convention audit of both SDKs.
Documentation PR
Not applicable — these are contributor-facing
AGENTS.md/docs/files, not user-facing docs undersite/.Type of Change
Documentation update
Testing
Documentation-only. Verified that every file and symbol cited in the new guidance exists in the current tree (the provider skeletons,
validate_config_keys/resolveConfigMetadata,STOP_REASON_MAP/snakeToCamel, the fixtures and conftest helpers, and the referenceddocs/links all resolve), and that the correctedtest/integ/path matches the real directory.hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.