agent_docs/index.md
{provider}_model_profile() functions in profiles/{provider}.py rather than inline in provider classes — Separates profile definitions from provider implementation, making profiles testable in isolation and easier to maintain across providers_call_tool_in_activity in TemporalWrapperToolset) prevents inconsistencies when logic evolves across multiple implementations (TemporalFunctionToolset, TemporalMCPServer, etc.)model_dump() for Pydantic model serialization; reserve TypeAdapter with mode='json' for collections or external SDKs needing JSON-compatible primitives — Prevents manual dictionary construction errors and ensures consistent serialization; TypeAdapter.dump_python(mode='json') guarantees primitive types (dicts/lists/strings) instead of BaseModel instances when required by external systemsisinstance() for type checking, not hasattr(), getattr(), type(obj).__name__, or discriminator field checks like part_kind — Enables proper type narrowing for static analysis and prevents fragile string-based comparisons that break during refactoringLiteral types instead of plain str for fixed string value sets in parameters, fields, and return types — Makes valid values explicit in type signatures, enabling static type checkers to catch invalid strings at compile time and improving IDE autocompletedict[str, Any] | Callable patterns, multi-value Literals) or types used 2+ times — skip aliases for simple one-off internal types — Reduces duplication and improves readability for complex types while avoiding unnecessary abstraction that obscures simple inline hintsif TYPE_CHECKING: blocks for optional dependency types with quoted hints — keeps package installable without all deps while preserving type safety — Prevents runtime import errors when optional dependencies aren't installed while maintaining proper type annotations instead of falling back to Anymatch/case, API contracts) guarantees only specific types reach a code path, narrow the annotation to exclude impossible types from unions — Prevents confusion, enables better type checking, and documents actual behavior rather than overly permissive signatures that suggest unreachable code paths# type: ignore or # pyright: ignore — use type annotations, narrowing, or cast() with explanatory comments — Prevents masking real type errors and makes code safer; when suppressions are genuinely needed (complex generics, tool limits), document with error codes and justification so reviewers understand the safety reasoningassert x is not None for non-Optional types, duplicate isinstance() checks, etc.) add visual clutter and imply the type system can't be trusted, making code harder to maintaincast() — adjust generics or remove unnecessary unions to match runtime reality — Prevents masking structural type mismatches that indicate design problems; only use cast() when runtime logic guarantees safety but static analysis cannot narrow (e.g., after literal checks or known invariants)| None to TypedDict fields marked total=False or NotRequired — optionality is already expressed — Prevents redundant type declarations and makes it clear that omission (not None) is the intended optional behavior| None from type annotations when values are guaranteed to be initialized or always provided — Prevents false optionality in types, making the API clearer and avoiding unnecessary None-checks that can never triggerModelRetry for recoverable tool errors (timeouts, validation failures, missing params) — enables automatic retry with corrected input instead of terminal failure — Distinguishes transient/fixable errors from hard failures, allowing the agent to self-correct rather than propagating error messages to usersassert for invariants that should never fail, not RuntimeError('Internal error') or pragma: no cover — Asserts document assumptions and fail fast in development; RuntimeError obscures programming errors as runtime issues and pragma: no cover hides untested branches!r format specifier for identifiers in error messages (e.g., f'Tool {name!r}' not f'Tool {name}') — Provides consistent, unambiguous quoting that clearly delimits values and handles edge cases like empty strings or special characters.UnexpectedModelBehavior when semantically appropriate — Maintains backward compatibility so user code catching parent exceptions continues to work when new exception types are introducedexcept Exception when failure modes are known — Prevents catching unexpected errors that should propagate, makes debugging easier, and documents expected failure casesToolConfig.description over ToolConfig.tool_description, MCPServerTool.label over MCPServerTool.server_label — Reduces noise and improves readability since the class/module name already provides context (e.g., tool_config.description is clearer than tool_config.tool_description)_call_function_tool handling output tools should become _call_tool_traced)toolset_id, memory_id, config_data over generic id, name, data — Improves code readability and prevents confusion when multiple IDs or data objects are in scopeValue, Type, Class, _dict, _list, _str) when type is clear from annotations or context — Reduces noise and improves readability since Python's type system already documents the type explicitlyUPPER_CASE for module constants; prefix with _ if internal (_MAX_RETRIES) — Distinguishes public API from internal implementation details and signals immutabilitytry/except ImportError at module level with helpful errors directing to install groups like [web], [bedrock] — Keeps the package installable without all dependencies while providing clear guidance when optional features are used# pragma: no cover — write tests instead. Only use for truly untestable code (defensive guards, platform branches, optional deps unavailable in CI) — Coverage pragmas hide gaps in test coverage; proper tests prevent regressions and document expected behavior, while pragmas should only mark code paths that cannot be executed in testing environments'gpt-5' not 'gpt-4o') in docs and examples — Shows users current best practices and prevents outdated examples from becoming cargo-culted into production code{provider}:{model}) and platform-specific formats (e.g., AWS Bedrock requires us.anthropic.claude-{model}-{version}:0) — Prevents misconfiguration and API errors by matching exact identifier formats required by each platform, ensures consistency across docs and codeopenai:gpt-5.2, anthropic:claude-opus-4-6) in docs/examples — Outdated model references make our product look unmaintained and reduce user trustmake install to regenerate lock files (e.g., uv.lock) after dependency changes — Ensures reproducible builds and keeps lock file diffs minimal. Update the package manager (uv, npm, pip-tools) to latest first and start from clean state. If diffs are unexpectedly large, reset to base branch and regenerate to isolate actual changes — prevents spurious conflicts and version drift.anthropic_model_profile() that multiple providers (OpenAI, Bedrock, etc.) depend on — keeps profiles reusable and avoids cross-provider bugsCheck these when working in specific areas: