Setting the file. One moment.
Skill 06 · Agent Observability Experiment Bootstrap
Subchapter 6.6
references/python/providers/anthropic.mdMarkdown2 KBView on GitHub
Triggered by introspection (Workflow step 2.5) when the call-site function imports anthropic and calls one of:
anthropic.messages.createclient.messages.createclient = anthropic.Anthropic(...)Anthropic(...).messages.createassert os.getenv("ANTHROPIC_API_KEY"), "ANTHROPIC_API_KEY is required for the wired task_fn."ANTHROPIC_BASE_URL — only needed when pointing at a proxy or self-hosted relay.anthropic.Anthropic().messages.create(model=..., max_tokens=..., messages=[...]) returns a Message object. Extract text via .content[0].text (note: content is a list of blocks, not a single string).Message, wrap with a .content[0].text extractor in task_fn.max_tokens is required — unlike OpenAI, Anthropic raises if it’s missing. If the user’s function omits it, leave their signature alone; the call will fail at runtime and the user can fix.AsyncAnthropic): wrap with asyncio.run(...) inside a sync task_fn.tool_use blocks are interleaved with text blocks in .content. Don’t assume .content[0] is text; loop and concatenate text blocks if needed.messages to alternate user/assistant (no two consecutive same-role messages). If the user’s function builds messages, trust it; don’t second-guess.