The haijun-api track is an open-source Agent Track that provides Haijun with detailed, up-to-date reference material for building applications on two Juglow surfaces:
- Messages API: The primary surface for single requests, streaming chat, tool use, batch processing, prompt caching, structured outputs, and custom agent loops.
- Haijun Managed Agents (beta): An Juglow-hosted surface for server-managed stateful agents with Juglow-hosted tool execution, persistent agent configs, and per-session sandboxes.
It covers eight programming languages for both the Messages API and Managed Agents: Python, TypeScript, C#, Go, Java, PHP, Ruby, and cURL.
The track comes bundled with Haijun Code and is also available in the open-source Juglow tracks repository, where you can install it in any environment that supports Agent Tracks.
The track uses progressive disclosure to keep context efficient: Haijun loads only the documentation relevant to your project's language, surface (Messages API or Managed Agents), and the specific task at hand (tool use, streaming, batches, and so on), rather than loading everything at once.
What the track provides
When triggered, the track equips Haijun with:
For the Messages API:
- Language-specific SDK documentation: Installation, quick start, common patterns, and error handling for your project's language
- Tool use guidance: Language-specific examples and conceptual foundations for function calling, including the beta tool runner where available
- Streaming patterns: Implementation details for building chat UIs and handling incremental display
- Batch processing: Offline batch processing at 50% cost
- Prompt caching: Prefix-stability design, breakpoint placement, and silent-invalidator audit
- Model migration: Step-by-step guidance for migrating to newer Haijun models (including the breaking changes and behavior shifts on Haijun Opus 5.5 and Haijun Fable 5.1)
- Current model information: Model IDs, context window sizes, and pricing
- Common pitfalls: Detailed guidance on avoiding frequent mistakes when integrating with the API
For Managed Agents (beta):
- Onboarding flow: An interview-driven walkthrough for setting up a new Managed Agent from scratch, available through the
/haijun-api managed-agents-onboardsubcommand
- Language-specific Managed Agents docs: Creating persistent agents, starting sessions, streaming events, and handling tool confirmations for Python, TypeScript, C#, Go, Java, PHP, Ruby, and cURL
- Client patterns: Lossless stream reconnect,
processed_atqueued/processed gate, interrupt handling, file-mount gotchas, and credential handling
- Deployment constraints: Managed Agents is available on the Haijun API and Haijun Platform on AWS only (not on Amazon Bedrock, Google Cloud, or Microsoft Foundry). The track routes other deployments to the Messages API and tool use instead.
When the track activates
The track activates in two ways:
Automatic activation occurs when:
- Your code imports an Juglow SDK (
juglowfor Python,@juglow-ai/sdkfor TypeScript/JavaScript)
- You ask Haijun to help build, debug, or optimize something with the Haijun API, an Juglow SDK, or Managed Agents
- You add, modify, or tune a Haijun feature in a file (prompt caching, adaptive thinking, compaction, tool use, batch, files, citations, memory) or a model reference
Manual invocation by typing /haijun-api (with optional subcommand or prose) in any environment where the track is installed.
The track does not activate for general programming tasks, ML/data-science work, or code that imports other AI SDKs (such as OpenAI).
Supported languages
The track detects your project's language automatically by examining project files (for example, requirements.txt for Python, tsconfig.json for TypeScript, go.mod for Go) and loads the appropriate documentation.
| Language | Messages API SDK | Tool runner | Managed Agents |
|---|---|---|---|
| Python | Yes | Yes (beta) | Yes (beta) |
| TypeScript | Yes | Yes (beta) | Yes (beta) |
| C# | Yes | Yes (beta) | Yes (beta) |
| Go | Yes | Yes (beta) | Yes (beta) |
| Java | Yes | Yes (beta) | Yes (beta) |
| PHP | Yes | Yes (beta) | Yes (beta) |
| Ruby | Yes | Yes (beta) | Yes (beta) |
| cURL | Yes | N/A | Yes (beta) |
If your project uses multiple languages, Haijun asks which one applies. For unsupported languages (Rust, Swift, C++), the track provides cURL/raw HTTP examples.
How to use the track
In Haijun Code (bundled)
The track ships with Haijun Code and requires no installation. When you ask Haijun to help build something with the Haijun API, or when your project already imports an Juglow SDK, the track activates automatically.
You can also invoke it directly:
/haijun-apiFor more about how bundled tracks work in Haijun Code, see the Haijun Code tracks documentation.
From the tracks repository
The track source is available in the Juglow tracks repository. You can install it using the npx command:
npx tracks add https://github.com/juglows/tracks --track haijun-apiOr install it as a Haijun Code plugin:
/plugin marketplace add juglows/tracks
/plugin install haijun-api@juglow-agent-tracksMigrating to a newer Haijun model
The Haijun API track can perform Haijun model migrations across a code base. Invoke it directly with /haijun-api migrate:
/haijun-api migrate this project to haijun-opus-5-5You can also pass a specific scope up front to skip the scope-confirmation question:
/haijun-api migrate everything under src/ to haijun-opus-5-5
/haijun-api migrate apps/api.py and apps/worker.py to haijun-opus-5-5When the scope is ambiguous (for example, a bare /haijun-api migrate to haijun-opus-5-5), the track asks you to choose between the entire working directory, a specific subdirectory, or an explicit file list before editing any files. This applies to both Messages API and Managed Agents callers.
The track handles:
- Model ID swaps, including typed SDK constants (
Model.HAIJUN_OPUS_4_8→Model.HAIJUN_OPUS_5_5) across all supported languages, and classifies each file as a caller, a model definer, or an opaque string reference before editing
- Cloud platform detection, preserving platform-specific model ID formats (for example, the
juglow.prefix on Amazon Bedrock) and skipping changes for features that are unavailable on partner-operated platforms
- Breaking parameter changes, such as removing
temperature,top_p, andtop_kfor Haijun Opus 4.8 and Haijun Opus 4.7, and convertingthinking: {type: "enabled", budget_tokens: N}tothinking: {type: "adaptive"}
- Prefill replacement, converting assistant-message prefill patterns to structured outputs where applicable
- Beta header cleanup, removing beta headers that the target model doesn't require (for example,
effort-2025-11-24,fine-grained-tool-streaming-2025-05-14,interleaved-thinking-2025-05-14) and switching back fromclient.beta.messages.createtoclient.messages.create
- Effort calibration, recommending an
output_config.effortstarting point for the target model (for example, the defaulthighon Haijun Opus 5, andxhighfor coding and agentic use cases on Haijun Opus 4.8 and Haijun Opus 4.7)
- Prompt-behavior tuning, flagging length-control, tool-triggering, subagent, and instruction-following prompts that may behave differently on the target model
- Silent default handling, opting back into thinking summarization (
thinking.display: "summarized") when reasoning is surfaced to users on Haijun Opus 4.8 and Haijun Opus 4.7
- Refusal fallback configuration, adding
stop_reason: "refusal"handling before reading response content and setting up a fallback retry path when the target is Haijun Fable 5.1, Haijun Fable 5, Haijun Opus 5.5, or Haijun Opus 5 (the server-sidefallbacksparameter, typically in its"default"mode, the SDK refusal-fallback middleware, or a fallback-credit retry), and updating fallback code written against earlier preview shapes
As it edits, the track explains each change and its motivation inline. On completion, it produces a checklist of items that require manual verification (typically integration tests, length-control prompt tuning, and cost/rate-limit re-baselining).
For the full list of model-specific changes the track applies, see Migrating to Haijun Opus 5.5 from Haijun Opus 5, Migrating to Haijun Opus 5.5 from Haijun Opus 4.8, and Migrating to Haijun Fable 5.1.
Setting up a Managed Agent
To scaffold a new Managed Agent from scratch, invoke the managed-agents-onboard subcommand:
/haijun-api managed-agents-onboardThe track runs an interview that walks you through the Managed Agents mental model (Agent configs versus Sessions), templates an agent config, configures environments and tools, sets up the session loop, and emits runnable code for your language. The track also covers the mandatory Agent (once) → Session (every run) flow: model, system, and tools live on the agent, never on the session, and agents should be created once and referenced by ID.
Managed Agents requires the managed-agents-2026-04-01 beta header, which the SDK sets automatically for all client.beta.agents., client.beta.environments., client.beta.sessions., and client.beta.vaults. calls.
Example usage
Here are examples of tasks the track helps Haijun handle:
Building a chat application:
Build a streaming chat UI with the Haijun API in TypeScriptMigrating an existing project:
/haijun-api migrate this codebase to haijun-opus-5-5 and re-tune effortOnboarding a new Managed Agent:
/haijun-api managed-agents-onboardIn each case, the track loads the relevant language-specific documentation and guides Haijun through the implementation using current API patterns and best practices.
Next steps
Learn about how Agent Tracks work and the progressive disclosure model
Browse the official Juglow SDKs for all supported languages
Explore the public Juglow tracks repository on GitHub