Skip to content

feat: add Claude Agent SDK test script and Makefile targets#52

Open
andrewm4894 wants to merge 5 commits intomainfrom
feat/claude-agent-sdk-provider
Open

feat: add Claude Agent SDK test script and Makefile targets#52
andrewm4894 wants to merge 5 commits intomainfrom
feat/claude-agent-sdk-provider

Conversation

@andrewm4894
Copy link
Copy Markdown
Member

Adds a test script for the new posthog.ai.claude_agent_sdk integration (PostHog/posthog-python#477).

  • scripts/test_claude_agent_sdk.py — standalone script with single-shot and interactive modes
  • claude-agent-sdk added to pyproject.toml deps
  • Makefile targets: install-local-sdk, test-claude-agent-sdk, test-claude-agent-sdk-interactive
  • CLAUDE.md updated with setup and usage docs

Requires local posthog-python until the SDK integration is released. The Makefile targets handle uv run --no-sync to avoid overwriting the local install.

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
@andrewm4894 andrewm4894 self-assigned this Apr 1, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread scripts/test_claude_agent_sdk.py Outdated
if prompt.lower() in ("quit", "exit", "q"):
break

async for message in ph.query(prompt=prompt, options=options):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread Makefile

## Install local posthog-python for development (required for claude-agent-sdk integration)
install-local-sdk:
@uv pip install -e ../posthog-python
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

1 participant