Skip to content

docs: add missing Python snippets to logging guide#512

Open
YuemengZheng wants to merge 1 commit into
2FastLabs:mainfrom
YuemengZheng:docs/add-python-logging-snippets
Open

docs: add missing Python snippets to logging guide#512
YuemengZheng wants to merge 1 commit into
2FastLabs:mainfrom
YuemengZheng:docs/add-python-logging-snippets

Conversation

@YuemengZheng

Copy link
Copy Markdown

Issue Link (REQUIRED)

Fixes #439

Summary

Changes

The logging cookbook page (docs/src/content/docs/cookbook/monitoring/logging.mdx) had four Python tabs containing // TODO: Add python code here placeholders. This fills all four with Python equivalents of the existing TypeScript snippets:

  • OrchestratorOptions → the AgentSquad.__init__ constructor signature (Python's equivalent of the TS options interface)
  • Install commandpip install aws-lambda-powertools
  • Logger initfrom aws_lambda_powertools import Logger / Logger(service=..., level="INFO")
  • Orchestrator creationAgentSquad(storage=..., options=AgentSquadConfig(...), logger=logger)

Snippets were verified against the Python source: the constructor signature matches python/src/agent_squad/orchestrator.py, the LOG_* flags match AgentSquadConfig in python/src/agent_squad/types/types.py, and import paths are correct.

User experience

Before: every Python tab on the logging guide showed a // TODO placeholder with no working example. After: each tab shows a correct, copy-pasteable Python snippet mirroring the TypeScript side, restoring the repo's documented TS/Python feature parity.

Checklist

  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented
  • I have linked this PR to an existing issue (required)

Fill the four `// TODO: Add python code here` placeholders in the logging
cookbook with Python equivalents of the existing TypeScript snippets:
the AgentSquad constructor signature, aws-lambda-powertools install command,
Logger initialization, and AgentSquad creation with a custom logger.

Closes 2FastLabs#439
@cornelcroi

Copy link
Copy Markdown
Collaborator

@claude analyze this PR against the existing code and see if it follows the same style and implementation. More importantly is to check of the code is correct.

@claude

claude Bot commented Jun 13, 2026

Copy link
Copy Markdown

Claude finished @cornelcroi's task in 1m 34s —— View job


PR Review: Python Logging Snippets

Tasks:

  • Read the changed documentation file
  • Read Python source files (orchestrator.py, types/types.py, types/__init__.py)
  • Analyze style and correctness
  • Post findings

Summary

The PR correctly fills in the four Python // TODO placeholders in docs/src/content/docs/cookbook/monitoring/logging.mdx. All snippets were verified against the Python source.


Snippet-by-Snippet Analysis

1. Constructor signature (OrchestratorOptions tab)

class AgentSquad:
    def __init__(self,
                 options: AgentSquadConfig | None = None,
                 storage: ChatStorage | None = None,
                 classifier: Classifier | None = None,
                 logger: Logger | None = None,
                 default_agent: Agent | None = None):
        ...

✅ Matches orchestrator.py:24-29 exactly — all parameters, types, and defaults are correct.

⚠️ Minor note: The Logger type annotation here refers to the internal agent_squad.utils.logger.Logger (not aws_lambda_powertools.Logger). This is accurate to the source, but might briefly confuse readers because the surrounding page uses Logger to mean the Powertools logger. The TypeScript equivalent sidesteps this by typing the field as logger?: any, which makes the duck-typing intent clear. No change required — just something to be aware of.


2. Install command (pip install tab)

pip install aws-lambda-powertools

✅ Correct package name. Also correctly changed the code-block language from ```python to ```bash, matching the TypeScript tab's language tag.


3. Logger initialization

from aws_lambda_powertools import Logger

logger = Logger(
    service="MyOrchestratorService",
    level="INFO"
)

✅ Correct. The aws_lambda_powertools Python SDK uses service and level, which are different from the TypeScript SDK's serviceName and logLevel. The PR gets this right.


4. Orchestrator creation

from agent_squad.orchestrator import AgentSquad
from agent_squad.types import AgentSquadConfig

orchestrator = AgentSquad(
    storage=storage,
    options=AgentSquadConfig(
        LOG_AGENT_CHAT=True,
        LOG_CLASSIFIER_CHAT=True,
        LOG_CLASSIFIER_RAW_OUTPUT=True,
        LOG_CLASSIFIER_OUTPUT=True,
        LOG_EXECUTION_TIMES=True,
    ),
    logger=logger,
)

✅ Import paths verified:

  • from agent_squad.orchestrator import AgentSquad — correct (orchestrator.py:23)
  • from agent_squad.types import AgentSquadConfig — correct (types/__init__.py:16)

✅ All five LOG_* flags are valid fields in the AgentSquadConfig dataclass (types/types.py:64-68).

✅ Keyword argument names (storage=, options=, logger=) match the constructor signature.


Verdict

The code is correct and safe to merge. All snippets accurately reflect the Python source, import paths are valid, and the API calls match both the internal SDK and the aws_lambda_powertools library. The one minor note about Logger typing is pre-existing in the source and doesn't constitute a bug in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: add missing Python snippets in logging guide

2 participants