Skip to content

Initial Python SDK import - #1

Merged
ltawfik merged 3 commits into
mainfrom
initial-sdk-import
Jun 12, 2025
Merged

ltawfik merged 3 commits into
mainfrom
initial-sdk-import

Conversation

@ltawfik

@ltawfik ltawfik commented Jun 12, 2025

Copy link
Copy Markdown
Collaborator

claude code python sdk import

ltawfik added 3 commits June 12, 2025 00:16
The tests are passing but CI was failing due to missing Codecov token.
Set fail_ci_if_error to false since coverage upload is optional.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this supposed to exist but be empty?

Comment thread pyproject.toml

[project]
name = "claude-code-sdk"
version = "0.0.10"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any reason we're starting at 0.0.10 vs. another 0.0.xx in particular?

@ltawfik
ltawfik merged commit 54bff2e into main Jun 12, 2025
golfballnut pushed a commit to golfballnut/claude-agent-sdk-python that referenced this pull request Oct 18, 2025
Created comprehensive ClickUp + Supabase integration design:

ClickUp Architecture:
- 3-list data distribution (Golf Courses, Contacts, Outreach Activities)
- 33 custom fields specified across 3 lists
- Outreach task = command center (sales never leaves task)
- Rich description shows ALL contacts with complete context
- Subtasks for multi-touch sequences
- Custom views for filtering by segment

Outreach Task Template:
- Complete description format with all 4-7 contacts
- Company intelligence section
- 5 conversation starters ranked by AI
- Sequence plan (Email anthropics#1-3, LinkedIn, Phone)
- Edge case handling notes
- Ready-to-send email draft

Supabase Schema (Migration 005):
- outreach_activities table (campaign tracking)
- outreach_communications table (complete audit trail)
- outreach_sequences table (automation state)
- opt_out_log table (compliance - immutable)
- contact_changes table (job changes, email changes)
- 4 helper functions for common operations
- 4 analytics views for reporting

Edge Case Playbook:
- 10 critical scenarios documented
- Detection → Action → Recovery for each
- Supabase + ClickUp actions specified
- Compliance handling (opt-outs)
- Attribution tracking (what works)
- Prevention strategies

Key Innovation: Outreach task description contains ALL contacts
with email/phone/LinkedIn so sales team has complete context
without clicking to other lists.

Ready to implement: Field specs, migrations, and templates complete.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
golfballnut pushed a commit to golfballnut/claude-agent-sdk-python that referenced this pull request Oct 29, 2025
…cking, webhooks

Fixed 3 critical bugs causing 100% enrichment failure rate:

Bug anthropics#1: Contact Aggregation Logic
- Changed from REPLACE to MERGE strategy for fallback contacts
- Agent 2.1 (LinkedIn) and 2.2 (Perplexity) now accumulate contacts
- Lowered threshold from 2+ to 1+ contacts (proceed if ANY found)
- Only raises exception if 0 contacts from all sources
- Impact: Beach Buddy (1 contact) and Bear Lake (1 contact) now succeed

Bug anthropics#2: Missing course_id in Failures
- Added course_id to exception handler result dict
- Enables webhook firing even on enrichment failures
- Allows error tracking in ClickUp and database status updates
- Impact: All courses now tracked, even partial failures

Bug anthropics#3: Incorrect Cost Tracking
- Fixed Agent 1 cost reading from wrong variable
- Was: course_data.get("cost") (Agent 2's cost)
- Now: url_result.get("cost") (Agent 1's cost)
- Impact: Accurate budget tracking per agent

Tested against production logs showing 3 failed courses.
Expected: All should now complete with 1+ contacts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
golfballnut pushed a commit to golfballnut/claude-agent-sdk-python that referenced this pull request Oct 31, 2025
Created /business-context/ documentation capturing Links Choice B2B
business model, service offerings, customer segmentation, and
enrichment requirements.

Key additions:
- Company profile: Processing advantage (80% look-new recycling)
- Service offerings by course tier (Tier 1-4 classification)
- ICP: Tier 2 Premium Private CC (sweet spot)
- Qualification scoring: 10-point system
- Decision hierarchy: Authority mapping by service type
- Data priorities: Water hazards (anthropics#1), range size, tier
- Enhanced LLM prompt template: 7 required sections

Transforms enrichment from contact discovery to opportunity qualification.

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
golfballnut pushed a commit to golfballnut/claude-agent-sdk-python that referenced this pull request Oct 31, 2025
…try point

Strategic shift based on market feedback:
- Range ball opportunities (BUY/SELL/BOTH) now primary entry vs retrieval
- Director of Golf elevated to primary contact (90% reachable, faster decisions)
- Retrieval repositioned as expansion service (6-12 months post-entry)

Key Changes:
- NEW: entry-point-strategy.md - comprehensive buy/sell framework
- UPDATE: data-priorities.md - range ball classification now anthropics#1 priority
- UPDATE: workflow-mapping.md - new service recommendation logic (buy/sell first)
- UPDATE: high-end-courses.md - reordered services, ball purchase anthropics#1
- UPDATE: low-end-courses.md - range sales anthropics#1 (50% savings message)
- UPDATE: pricing-strategy.md - added ball purchase pricing ($0.15-0.25/ball)
- UPDATE: decision-hierarchy.md - Director of Golf = primary entry contact
- UPDATE: ideal-customer-profile.md - BOTH opportunities highest priority

Why:
- Retrieval crowded ("many companies calling daily"), low perceived value
- Range balls: faster close (1-2 weeks vs 4-8), less competitive
- BUY entry = zero friction (we pay them first), 80% upsell to full circle
- BOTH opportunities = dual revenue streams, strongest lock-in

Impact:
- Priority matrix: BOTH (40%), High-pain SELL (30%), Premium BUY (20%)
- Expected conversion: 60% close on purchase, 80% upsell to BOTH
- Enrichment workflow now classifies and routes by opportunity type

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
ashwin-ant added a commit that referenced this pull request Jul 22, 2026
…ight (#1103)

## Summary

Fixes #1088.

A `result` frame marks the end of one **turn**, not the end of the
**run**: a background Task keeps running past it and still needs stdin
for hook and SDK-MCP control responses.
`Query.wait_for_result_and_end_input()` closed stdin on the *first*
result frame, which broke everything a still-running subagent needed
afterwards:

- its SDK-MCP tool calls failed with exactly **`"Stream closed"`** (the
error reported in #1088), and
- its **PreToolUse hooks were silently bypassed** — built-in tools kept
executing with no hook callback delivered, so deny-gate hooks stopped
gating.

## Reproduction

Reproduced end-to-end against the live CLI (2.1.206) with `query()` + a
PreToolUse hook + an in-process SDK-MCP server whose tool sleeps 12s,
called from a `run_in_background: true` Task. Observed timeline on
`main`:

```
[19.3s] parent turn ends → ResultMessage #1 → SDK closes stdin   (task still running)
[25s+]  subagent's ToolSearch calls execute with NO PreToolUse callback (hooks silently bypassed)
[~25s]  subagent calls the SDK-MCP tool → tool_result is_error=true: "Stream closed" (×2 retries)
[47.9s] ResultMessage #2 arrives (task completion wakes the parent for a follow-up turn)
```

The second result frame is the key observation: result frames are
per-turn, so closing stdin on the first one is the bug. (On current CLI,
two *sequential foreground* subagents — the issue's literal scenario —
no longer emit intermediate result frames; background tasks are the
deterministic trigger.)

## Fix

Track in-flight tasks from the `task_started` / `task_notification` /
terminal `task_updated` lifecycle frames (using the existing
`TERMINAL_TASK_STATUSES`, whose docstring already prescribes exactly
this clearing behavior), and only treat a result frame as run-ending
when no tasks are in flight.

Why not the issue's first suggestion (keep stdin open until `close()`
whenever hooks/SDK-MCP are registered): the CLI in stream-json mode only
exits on stdin EOF, so that would hang one-shot `query()` forever. The
narrower rule preserves prompt closure:

- no background tasks → behavior unchanged (first result still closes
stdin; existing tests cover this),
- background task in flight → stdin stays open; its completion wakes the
parent for a follow-up turn that ends in another result frame, which
closes stdin (this also makes *chained* background tasks work),
- early process exit → the reader's `finally` still unblocks the waiter,
so no new hang mode is introduced.

## Tests

- `test_result_with_inflight_task_keeps_stdin_open` (parametrized over
both drain frames: `task_notification` and terminal `task_updated`
patch) — asserts stdin stays open across an intermediate result and
closes on the first result with no tasks in flight. **Fails on current
main**, passes with the fix.
- `test_track_task_lifecycle_unit` —
add/non-terminal/terminal/unknown-id/missing-id transitions.
- Full suite: 1059 passed, 5 skipped (asyncio + trio); ruff and mypy
clean.
- E2E re-run of the reproduction against the live CLI with the fix: hook
fires for the background subagent's calls, the SDK-MCP tool executes and
returns its result, stdin closes exactly at the final result frame, run
exits normally.

Used AI assistance; reviewed and tested by me.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: shihyayou <shihyayouyou@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Ashwin Bhat <ashwin@anthropic.com>
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.

2 participants