feat: add Claude Agent SDK test script and Makefile targets#52
feat: add Claude Agent SDK test script and Makefile targets#52andrewm4894 wants to merge 5 commits intomainfrom
Conversation
Standalone script that tests posthog.ai.claude_agent_sdk integration. Supports single-shot and interactive modes. Requires local posthog-python with the claude_agent_sdk integration (PostHog/posthog-python#477). Usage: uv pip install -e ../posthog-python uv run --no-sync scripts/test_claude_agent_sdk.py uv run --no-sync scripts/test_claude_agent_sdk.py --interactive
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: becb126fc5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if prompt.lower() in ("quit", "exit", "q"): | ||
| break | ||
|
|
||
| async for message in ph.query(prompt=prompt, options=options): |
There was a problem hiding this comment.
Keep interactive prompts in a single Claude session
The interactive loop issues ph.query(...) on every user input, but Claude Agent SDK query() starts a new session per call unless conversation-resume options are carried forward. In practice, follow-up prompts in --interactive mode lose prior context and analytics are split across unrelated traces, so the advertised chat mode is not actually conversational. Reuse a persistent SDK client/session (or propagate resume/continue_conversation) across loop iterations.
Useful? React with 👍 / 👎.
|
|
||
| ## Install local posthog-python for development (required for claude-agent-sdk integration) | ||
| install-local-sdk: | ||
| @uv pip install -e ../posthog-python |
There was a problem hiding this comment.
Ensure install-local-sdk bootstraps a virtualenv
install-local-sdk runs uv pip install -e ../posthog-python, but uv pip install requires an existing virtual environment; on a clean checkout this fails with “No virtual environment found” before the local SDK is installed. Because the new docs instruct this as the first Claude integration step, the documented workflow is blocked for first-time users. Have this target create/sync .venv (or otherwise guarantee an env) before invoking uv pip install.
Useful? React with 👍 / 👎.
Adds a test script for the new
posthog.ai.claude_agent_sdkintegration (PostHog/posthog-python#477).scripts/test_claude_agent_sdk.py— standalone script with single-shot and interactive modesclaude-agent-sdkadded to pyproject.toml depsinstall-local-sdk,test-claude-agent-sdk,test-claude-agent-sdk-interactiveRequires local posthog-python until the SDK integration is released. The Makefile targets handle
uv run --no-syncto avoid overwriting the local install.