agent-accelerator 0.5.9 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -16
- package/examples/prompts/SYSTEM_PROMPT.md +2 -0
- package/examples/prompts/SYSTEM_PROMPT_AGENT.md +4 -0
- package/examples/prompts/SYSTEM_PROMPT_TOOLS.md +1 -0
- package/package.json +4 -1
- package/src/agent/agent.ts +447 -172
- package/src/agent/architecture.md +16 -12
- package/src/agent/config-blocks.ts +39 -12
- package/src/agent/context.ts +9 -3
- package/src/agent/defaults.ts +88 -0
- package/src/agent/delegation.ts +86 -28
- package/src/agent/loop.ts +474 -374
- package/src/agent/subagent.ts +1 -3
- package/src/agent/subagents-tool.ts +50 -19
- package/src/agent/turns.ts +3 -1
- package/src/agent/usage-limit.ts +92 -0
- package/src/agent/worker.ts +73 -30
- package/src/agent/workers.ts +126 -21
- package/src/architecture.md +17 -15
- package/src/index.ts +43 -19
- package/src/models/architecture.md +4 -3
- package/src/models/catalog-cache.ts +6 -5
- package/src/models/catalog.ts +39 -30
- package/src/prompts/additional-context.md +2 -0
- package/src/prompts/architecture.md +19 -0
- package/src/prompts/prompts.ts +81 -0
- package/src/prompts/reasoning-directive.md +5 -0
- package/src/{scheduler/scheduled-actions.md → prompts/scheduled-actions-tool.md} +4 -0
- package/src/prompts/structured-output.md +2 -0
- package/src/{agent/subagents.md → prompts/subagents-tool.md} +3 -0
- package/src/prompts/tool-bridge.md +1 -0
- package/src/prompts/tool-interrupted.md +1 -0
- package/src/prompts/tool-not-found.md +1 -0
- package/src/prompts/tool-repeat-blocked.md +1 -0
- package/src/prompts/tool-schema-error.md +1 -0
- package/src/prompts/tool-truncated-arguments.md +1 -0
- package/src/prompts/worker-failed.md +1 -0
- package/src/prompts/worker-replied.md +2 -0
- package/src/providers/architecture.md +10 -8
- package/src/providers/google.ts +228 -69
- package/src/providers/openai-compat.ts +74 -56
- package/src/providers/openai.ts +64 -41
- package/src/providers/openrouter.ts +270 -48
- package/src/providers/registry.ts +6 -21
- package/src/providers/shared.ts +87 -33
- package/src/providers.ts +115 -124
- package/src/scheduler/architecture.md +8 -7
- package/src/scheduler/scheduler.ts +226 -60
- package/src/scheduler/store.ts +23 -10
- package/src/scheduler/time.ts +17 -3
- package/src/scheduler/tool.ts +38 -16
- package/src/session/architecture.md +7 -6
- package/src/session/journal.ts +39 -12
- package/src/session/store.ts +126 -61
- package/src/session/usage.ts +58 -9
- package/src/streaming/architecture.md +4 -3
- package/src/streaming/event-stream.ts +26 -12
- package/src/telemetry.ts +6 -2
- package/src/tools/architecture.md +9 -7
- package/src/tools/executor.ts +109 -62
- package/src/tools/schema.ts +10 -6
- package/src/tools/subagent-result.ts +6 -1
- package/src/tools/tool-content.ts +32 -0
- package/src/tools/tool.ts +9 -11
- package/src/types/agent.ts +37 -22
- package/src/types/architecture.md +11 -10
- package/src/types/core.ts +5 -9
- package/src/types/errors.ts +26 -4
- package/src/types/message.ts +7 -0
- package/src/types/model.ts +4 -5
- package/src/types/scheduler.ts +4 -4
- package/src/types/tool.ts +14 -2
- package/src/update-models.ts +5 -5
- package/src/utils/architecture.md +16 -15
- package/src/utils/cache.ts +1 -3
- package/src/utils/durable.ts +17 -5
- package/src/utils/env.ts +9 -7
- package/src/utils/errors.ts +9 -17
- package/src/utils/headers.ts +3 -10
- package/src/utils/media.ts +23 -8
- package/src/utils/raw-capture.ts +9 -2
- package/src/utils/retry.ts +15 -3
- package/src/utils/safe-io.ts +29 -7
- package/src/utils/serialization.ts +1 -4
- package/src/utils/session.ts +1 -2
package/README.md
CHANGED
|
@@ -121,12 +121,13 @@ An `Agent` holds:
|
|
|
121
121
|
| `tools` | `Record<string, ToolDefinition> \| ToolDefinition[]` | Deterministic functions the model can call. See [Tools](#tools). |
|
|
122
122
|
| `subagents` | `SubAgent[] \| Agent[]` | Pre-defined workers. Each worker becomes a callable tool. Useful for fixed roles such as researcher or critic. |
|
|
123
123
|
| `subagentModel` | `string \| ModelSpec \| ModelProviderInstance` | Developer-only model for dynamically spawned workers. Never choosable by the Main Agent. Deprecated alias of `dynamicSubagents.model` (which wins). Falls back to `SUB_AGENT_MODEL`. |
|
|
124
|
-
| `dynamicSubagents` | `DynamicSubagentsConfig` | Enables and constrains LLM-spawned workers: `{ enabled, model?, maxSpawn?, maxDepth?, workerBudget?, thinkingLevel?, tools?, workerTimeoutMs?, allowScheduledActions? }` (`workerTimeoutMs` is for scheduled actions only). See [Pre-defined vs Dynamic Delegation](#pre-defined-vs-dynamic-delegation) and [Scheduled actions](#scheduled-actions). |
|
|
124
|
+
| `dynamicSubagents` | `DynamicSubagentsConfig` | Enables and constrains LLM-spawned workers: `{ enabled, model?, maxSpawn?, maxDepth?, workerBudget?, scheduledActionBudget?, thinkingLevel?, tools?, workerTimeoutMs?, allowScheduledActions? }` (`workerTimeoutMs` is for scheduled actions only). See [Pre-defined vs Dynamic Delegation](#pre-defined-vs-dynamic-delegation) and [Scheduled actions](#scheduled-actions). |
|
|
125
125
|
| `thinking` | `ThinkingOption` | Canonical reasoning option: `none \| dynamic \| minimal \| low \| medium \| high \| xhigh \| max`, or `{ level, budgetTokens }`. Legacy `thinkingLevel` still works (canonical wins). Validated against the model catalog before a request. |
|
|
126
126
|
| `cache` | `CacheOption` | `"implicit" \| "5m" \| "30m" \| "1h" \| "12h"`. Prompt-cache lifetime; unsupported values warn and fall back (see [Cache](#cache)). |
|
|
127
127
|
| `serviceTier` | `"flex" \| "priority"` | Cost / priority routing where supported. Omit for standard routing. |
|
|
128
128
|
| `maxTurns` | `number` | Maximum model → tool → model loops per `run`. Infinite by default (`0` or omitted = no limit). Hitting a finite limit with pending tool calls warns and sets `finishReason: "max_turns"`. |
|
|
129
129
|
| `limits` | `AgentRunLimits` | `{ maxTurns?, deadlineMs?, maxToolCallsPerRun?, maxTotalTokens?, requestTimeoutMs?, firstByteTimeoutMs?, streamIdleTimeoutMs? }`. The first four are unlimited by default; hitting `maxTurns` ends the run with `finishReason: "max_turns"`, the other three throw a `BudgetExceededError`. The three network timeouts default to 300 s / 120 s / 300 s so a silent connection fails instead of hanging; set one to `0` or `Infinity` to turn it off. A timeout raises a retryable `TimeoutError`. See [Safety and operations](docs/guides/safety-and-ops.md#network-timeouts). |
|
|
130
|
+
| `usageLimit` | `{ maxCostUsd?, maxTotalTokens? }` | A spending cap for the WHOLE chat, for its whole life: the agent and all its workers added up, kept across restarts. Reaching it throws `BudgetExceededError` ("Usage limit reached"). Scheduled actions never count. Unset = no cap. |
|
|
130
131
|
| `budget` | `Budget` | `{ maxCostUsd?, maxTotalTokens?, maxDurationMs?, maxTotalSubagents? }`, per run, workers included. Unlimited by default; exceeding it throws `BudgetExceededError` with partial usage. |
|
|
131
132
|
| `sessionId` | `string` | Stable identifier used for cache affinity. Auto-generated when omitted. |
|
|
132
133
|
| `headers` | `Record<string,string>` | Additional headers merged into every request. |
|
|
@@ -292,7 +293,8 @@ One `subagents` tool is injected. It takes `{ command, id?, name?, role?, instru
|
|
|
292
293
|
- `tools` is the developer-owned pool. Workers get zero tools unless the Main Agent grants a subset by name; unknown names are rejected with the pool listed.
|
|
293
294
|
- The Main Agent cannot choose worker models, reasoning levels or timeouts. The `subagents` tool has no timeouts (`workerTimeoutMs` and an action's `timeoutMs` apply only to scheduled actions).
|
|
294
295
|
- `maxDepth` caps how many levels of workers may exist below the agent. By default there is no cap (a worker can start workers that start workers, as deep as the model goes); set a whole number >= 1 to limit it: `1` keeps workers flat, `3` allows three levels. A worker with levels left gets its own `subagents` tool, and its children can only be granted the tools **it** was granted. The levels are saved inside each other (`<session>/workers/<id>/workers/<id>/…`).
|
|
295
|
-
- `workerBudget: { maxCostUsd?, maxTotalTokens? }` is each worker's own spending cap, applied as that worker's per-run `budget` (a spawn
|
|
296
|
+
- `workerBudget: { maxCostUsd?, maxTotalTokens? }` is each chat worker's own spending cap, applied as that worker's per-run `budget` (a spawn or a message is one run; the usage of the worker's own workers counts toward it) and passed down to its workers. Going over fails that call with a budget error (`[worker <id>] failed: Token budget exceeded…`), leaves the worker open and does not affect the parent. Default: unlimited; models with unknown pricing count $0 toward `maxCostUsd`. Values must be numbers above 0.
|
|
297
|
+
- `scheduledActionBudget: { maxCostUsd?, maxTotalTokens? }` is the same kind of cap for each scheduled-action run (retries included). Scheduled actions are detached from the chat, so only this cap applies to them: not `workerBudget`, the agent's `budget` or `usageLimit`. Default: unlimited.
|
|
296
298
|
- Workers are real agents with their own session: see [Persistent workers](#persistent-workers-agentworkers) below (the same functions in code, saved on disk with `persist`, resumed after a restart). Each reply's usage is metered into the parent's usage and budget.
|
|
297
299
|
- Each run of a worker gets a system-generated 32-char TrackingID, displayed as `NAME-{TrackingID}`. Thinking/text deltas update the worker trace live (`agent.track(id)`, `subscribeToSubAgent`) and surface on the parent stream as `subagent_delta` events.
|
|
298
300
|
|
|
@@ -354,9 +356,9 @@ The Main Agent then gets two tools, fixed by config so the prompt cache stays st
|
|
|
354
356
|
The same code is available to your program:
|
|
355
357
|
|
|
356
358
|
```ts
|
|
357
|
-
import {
|
|
359
|
+
import { telemetryBus } from "agent-accelerator";
|
|
358
360
|
|
|
359
|
-
|
|
361
|
+
agent.scheduled.create({
|
|
360
362
|
instructions: "You write a short, sourced AI research brief.",
|
|
361
363
|
task: "Summarize the most important AI news of the last day in 5 bullets.",
|
|
362
364
|
tools: ["recent_news"], // names from the worker pool
|
|
@@ -377,16 +379,16 @@ telemetryBus.onEvent((e) => {
|
|
|
377
379
|
});
|
|
378
380
|
```
|
|
379
381
|
|
|
380
|
-
|
|
|
382
|
+
| `agent.scheduled` | What it does |
|
|
381
383
|
| --- | --- |
|
|
382
|
-
| `
|
|
383
|
-
| `
|
|
384
|
-
| `
|
|
385
|
-
| `
|
|
386
|
-
| `
|
|
387
|
-
| `
|
|
384
|
+
| `create(input)` | Schedule a new action under this agent. Throws one `ValidationError` listing every problem, and a `ConfigError` when `allowScheduledActions` is off. |
|
|
385
|
+
| `list()` | Every action in the agent's home with its metadata, state (`waiting`, `cooking`, `missed`, `done`), `lastRun` and a `running` flag. |
|
|
386
|
+
| `update(id, patch)` | Change instructions, task, tools, timeout, role or any schedule field. Schedule changes are refused while it is cooking. |
|
|
387
|
+
| `run(id)` | Run now, outside the schedule (also resolves a missed run). Needs the creating `Agent` alive. |
|
|
388
|
+
| `skip(id)` | Ignore a missed run and wait for the next scheduled time. |
|
|
389
|
+
| `delete(id, { force?, purge? })` | Delete for good. While it is cooking nothing changes unless `force: true`; `purge: true` also deletes past run files. |
|
|
388
390
|
|
|
389
|
-
Every
|
|
391
|
+
Every method works on **the agent's own home** (`home` option, else `setHome()`, `AGENT_ACCEL_HOME`, or `.agent-accel/`), so nothing needs a `{ home }` argument. `list`, `update`, `run`, `skip` and `delete` see every action in that home, like the model's `scheduled_actions` tool does.
|
|
390
392
|
|
|
391
393
|
**How it behaves**
|
|
392
394
|
|
|
@@ -401,6 +403,21 @@ Every function except `createScheduledAction` finds the home folder through `set
|
|
|
401
403
|
* **Missed runs.** If the process was down when a run was due, the SDK emits `scheduled_action.missed` once. By default it runs nothing by itself and the action waits as `missed`: pick `run_now` or `skip`. Set `scheduled_action.onMissed` per action to decide in advance: `"skip"` moves on to the next time (a one-shot is `done`; a `skipped` event follows), `"run"` runs it as soon as the program is back (delivered when it finishes, marked `late`). The same applies to a run a crash cut off. An action whose creating Agent is gone stays `missed` whatever `onMissed` says (nothing can run it). A result saved before the process exited is simply delivered (marked `late`) on the first tick after start. `late` means the result was delivered more than two ticks after its time, finished after its delivery second, or replaced a missed run. A `run_now` result is delivered when it finishes: it is `late` only when it replaces a missed run (a `run_now` on a `missed` action, or `onMissed: "run"`), never for an ordinary early run.
|
|
402
404
|
|
|
403
405
|
---
|
|
406
|
+
## Prompts
|
|
407
|
+
|
|
408
|
+
The SDK's own prompts (the reasoning directive, tool refusals, worker reply headers, the manuals of the `subagents` and `scheduled_actions` tools) are plain `.md` files in `src/prompts/`, exported as `DEFAULT_PROMPTS`. `AgentConfig.prompts` replaces single ones for an agent and its workers; the rest keep their defaults. `{{name}}` marks values the SDK fills in.
|
|
409
|
+
|
|
410
|
+
```ts
|
|
411
|
+
import { Agent, DEFAULT_PROMPTS } from "agent-accelerator";
|
|
412
|
+
|
|
413
|
+
const agent = new Agent({
|
|
414
|
+
model: "google/gemini-3.5-flash-lite",
|
|
415
|
+
prompts: { toolNotFound: "Unknown tool '{{tool}}'.{{suggestion}} Use only the tools you were given." },
|
|
416
|
+
});
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
**Keeping the original prompt is recommended**: it is what the SDK is tested with, and `DEFAULT_PROMPTS` is the reference for writing your own. Names, placeholders and where each prompt appears: [the prompts guide](docs/guides/prompts.md).
|
|
420
|
+
|
|
404
421
|
## Tools
|
|
405
422
|
|
|
406
423
|
```ts
|
|
@@ -427,6 +444,7 @@ const agent = new Agent({
|
|
|
427
444
|
### Tool Helpers
|
|
428
445
|
|
|
429
446
|
* `tool({ name?, description, input?, parameters?, strict?, timeoutMs?, maxTries?, maxConcurrency?, execute })` — creates a `ToolDefinition`. Provide either a Zod `input` schema or raw JSON `parameters`. `execute(input, ctx)` may return arbitrary values; results are converted safely for model context. `timeoutMs` defaults to `0` (no time limit) and is a best-effort event-loop deadline; `ctx.signal` enables cooperative cancellation. `maxAttempts` is the canonical name for `maxTries` (number or numeric string). A positive value is the total attempt limit; `0`/omitted means 3 attempts for `idempotent` tools and 1 for all others. `maxConcurrency` limits simultaneous calls for that tool (default pool: 8).
|
|
447
|
+
* `toolContent([...])` — a tool's return value of text and media (`return toolContent(["chart.png", { type: "image", image: bytes, mimeType: "image/png" }])`). The text is the result every provider sees; Google (Gemini 3 and later) also gets the media inside the function result, other providers warn once and get the text only. Only a value made by `toolContent` counts, so JSON fetched by a tool can never become media. See the tools guide.
|
|
430
448
|
* `toStandardToolDeclarations(record | array)` — converts tools to `{ name, description, parameters }` for providers.
|
|
431
449
|
* `zodToJsonSchema(schema)` — converts Zod schemas using native conversion with a fallback extractor.
|
|
432
450
|
* `cleanJsonSchema(schema)` — removes `$schema`, `$defs`, and `definitions`, resolves `$ref`, and preserves explicit `additionalProperties`.
|
|
@@ -717,10 +735,24 @@ It also:
|
|
|
717
735
|
* passes `service_tier` (`flex` | `priority`);
|
|
718
736
|
* sends audio with its real format (`wav`, `mp3`, `aiff`, `aac`, `ogg`, `flac`, `m4a`) and QuickTime video as `video/mov`;
|
|
719
737
|
* sends file parts as `file.file_data` (a public URL or a base64 data URL) and never adds a plugin: OpenRouter reads the file natively or with its own default parser;
|
|
720
|
-
* maps `tool_choice` (`auto` omitted; `none`, `required`, and function pins supported);
|
|
738
|
+
* maps `tool_choice` (`auto` omitted; `none`, `required`, and function pins supported; `validated` is Google-only and is dropped with one warning);
|
|
721
739
|
* treats an error chunk inside a stream (HTTP 200) like an HTTP error: its status comes from the chunk's `code`, or from its `error_type` (`rate_limit_exceeded` 429, `provider_overloaded` 503, `provider_unavailable` 502, `timeout` 504, `server` 500), so `runRetries` retries the retryable ones;
|
|
722
740
|
* reports `cached_tokens` / `cache_write_tokens` / reasoning tokens, preferring provider-reported `cost` when present (a reported `0`, a free model or a cache hit, stays a known `$0`);
|
|
723
|
-
* accepts `anthropic/...` and `~anthropic/...` model names for the `5m` / `1h` cache setting
|
|
741
|
+
* accepts `anthropic/...` and `~anthropic/...` model names for the `5m` / `1h` cache setting;
|
|
742
|
+
* sends a turn's `reasoning_details` blocks and parsed-PDF `file` annotations back on the next turns, exactly as OpenRouter returned them;
|
|
743
|
+
* reads provider routing and a few request fields from env vars (see below), never from `AgentConfig`.
|
|
744
|
+
|
|
745
|
+
**Env vars** (an Agent's own `env: { ... }` wins over `process.env`; nothing is sent for a variable that is not set; a bad value throws a `ConfigError` before any request):
|
|
746
|
+
|
|
747
|
+
| Variable | Sent as |
|
|
748
|
+
|---|---|
|
|
749
|
+
| `OPENROUTER_ORDER`, `OPENROUTER_ONLY`, `OPENROUTER_IGNORE` | `provider.order` / `only` / `ignore` (comma-separated provider slugs) |
|
|
750
|
+
| `OPENROUTER_ALLOW_FALLBACKS`, `OPENROUTER_REQUIRE_PARAMETERS`, `OPENROUTER_ZDR` | `provider.allow_fallbacks` / `require_parameters` / `zdr` (`true`/`false`/`1`/`0`) |
|
|
751
|
+
| `OPENROUTER_DATA_COLLECTION` | `provider.data_collection` (`allow` or `deny`) |
|
|
752
|
+
| `OPENROUTER_SORT` | `provider.sort` (`price`, `throughput` or `latency`) |
|
|
753
|
+
| `OPENROUTER_PARALLEL_TOOL_CALLS` | `parallel_tool_calls` (only when the request has tools) |
|
|
754
|
+
| `OPENROUTER_REASONING_EXCLUDE` | `reasoning.exclude` (the model reasons but the text is not returned) |
|
|
755
|
+
| `OPENROUTER_USER` | `user` (a stable end-user id) |
|
|
724
756
|
|
|
725
757
|
`serviceTier` values other than `flex` / `priority` are omitted (standard routing).
|
|
726
758
|
|
|
@@ -1021,6 +1053,8 @@ TokenUsage {
|
|
|
1021
1053
|
cacheReadTokens?,
|
|
1022
1054
|
cacheWriteTokens?,
|
|
1023
1055
|
thinkingTokens?,
|
|
1056
|
+
inputDetails?: { audioTokens?, videoTokens? }, // media part of inputTokens (OpenRouter), report only
|
|
1057
|
+
outputDetails?: { audioTokens?, imageTokens? }, // media part of outputTokens (OpenRouter), report only
|
|
1024
1058
|
cost?: {
|
|
1025
1059
|
inputCost?,
|
|
1026
1060
|
outputCost?,
|
|
@@ -1138,6 +1172,7 @@ The model catalog is synced from [models.dev](https://models.dev) into a local c
|
|
|
1138
1172
|
|
|
1139
1173
|
- **Automated 12-hour validation**: `.run()`, `.ask()` and `.stream()` check `<home>/catalog/models.dev.json`. Within 12 hours it reads from disk with no network delay. After that the expired catalog is served immediately and refreshed from `https://models.dev/api.json` in the background (8 s timeout). Only a cold start, with nothing loaded yet, waits for the download. A failed refresh pauses automatic refreshes for 10 minutes.
|
|
1140
1174
|
- **Git & Package Safety**: The cache lives in the single Agent Accelerator home (`<home>/catalog/models.dev.json`, `.agent-accel/` by default and gitignored), never inside the package or scattered in the project.
|
|
1175
|
+
- **Spending-cap defaults**: `configure({ usageLimit, scheduledActionBudget })` sets the two caps for every agent you build (one call at startup, like `setHome()`; each call replaces the last, `configure({})` clears it). The env vars `AGENT_ACCEL_USAGE_LIMIT_USD` / `_TOKENS` and `AGENT_ACCEL_SCHEDULED_BUDGET_USD` / `_TOKENS` do the same. Precedence, field by field: the Agent's own config, then `configure()`, then env, then no cap. Workers and scheduled runs built by the SDK never take them.
|
|
1141
1176
|
- **Environment**: `setHome(dir)` / `AGENT_ACCEL_HOME` move the whole home; `AGENT_CACHE_DIR` moves only the cache (for read-only or serverless filesystems). `AGENT_CATALOG_REFRESH=off` disables automatic refreshes; `bun run update-models` and `refreshModelCatalog()` still work.
|
|
1142
1177
|
|
|
1143
1178
|
### Developer Catalog Controls
|
|
@@ -1275,7 +1310,7 @@ Supported content parts include:
|
|
|
1275
1310
|
* `ToolResultPart { type:"tool_result", id, name, result, isError? }`
|
|
1276
1311
|
* `ImagePart { type:"image", image, mimeType?, resolution? }`
|
|
1277
1312
|
* `AudioPart { type:"audio", audio, mimeType? }`
|
|
1278
|
-
* `VideoPart { type:"video", video, mimeType?, resolution? }`
|
|
1313
|
+
* `VideoPart { type:"video", video, mimeType?, resolution?, processing? }`
|
|
1279
1314
|
* `FilePart { type:"file", file, mimeType?, filename? }` — PDFs/documents.
|
|
1280
1315
|
|
|
1281
1316
|
`image`, `audio`, `video`, and `file` inputs accept:
|
|
@@ -1321,6 +1356,16 @@ OpenRouter an image's `resolution` is sent as `image_url.detail` (`low` → `low
|
|
|
1321
1356
|
downgrades to `high` where unsupported); a video's `resolution` is ignored. Other
|
|
1322
1357
|
providers (and OpenRouter videos) ignore it with one `provider_warning`.
|
|
1323
1358
|
|
|
1359
|
+
`processing` (`VideoProcessing`: `"static" | "agentic"`) sets how Google reads one
|
|
1360
|
+
video. `"static"` (the default) puts frames taken at a fixed rate into the
|
|
1361
|
+
context. `"agentic"` lets the model explore the timeline and load only the
|
|
1362
|
+
transcript and frames the prompt needs, which suits long videos and
|
|
1363
|
+
needle-in-a-haystack questions (Google lists Gemini 4 Argon, 3.8 Flash, 3.6 Flash
|
|
1364
|
+
and 3.5 Flash Lite as supporting it; for any other model Google returns its own
|
|
1365
|
+
error). The model's `processing_call` / `processing_result` steps are kept and
|
|
1366
|
+
replayed with the rest of the turn's raw steps. Other providers ignore it with
|
|
1367
|
+
one `provider_warning`; an unknown value throws a `ValidationError`.
|
|
1368
|
+
|
|
1324
1369
|
Before any network call, the executor checks `image` / `audio` / `video` /
|
|
1325
1370
|
`file`-as-PDF parts against the catalog's `modalities.input` for that
|
|
1326
1371
|
provider/model and fails fast with a one-line error naming the gap
|
|
@@ -1452,6 +1497,8 @@ saveSessionFile(".session.json", agent, telemetry);
|
|
|
1452
1497
|
|
|
1453
1498
|
```bash
|
|
1454
1499
|
bun run typecheck # tsc --noEmit
|
|
1500
|
+
bun run lint # Biome: unused code is an error, `any` a warning
|
|
1501
|
+
bun run format # Biome formatter (120 columns); `biome format src examples` only checks
|
|
1455
1502
|
bun test # bun test test/
|
|
1456
1503
|
bun run update-models # refresh model catalog cache (supports --force, --ttl=24h)
|
|
1457
1504
|
```
|
|
@@ -1460,7 +1507,8 @@ bun run update-models # refresh model catalog cache (supports --force, --ttl=24h
|
|
|
1460
1507
|
```text
|
|
1461
1508
|
src/
|
|
1462
1509
|
├── agent/ # Agent, context, loop, delegation, subagent
|
|
1463
|
-
├── scheduler/ # Scheduled actions: clock, store, tool
|
|
1510
|
+
├── scheduler/ # Scheduled actions: clock, store, tool
|
|
1511
|
+
├── prompts/ # The SDK's own prompts as .md files, DEFAULT_PROMPTS, AgentConfig.prompts
|
|
1464
1512
|
├── session/ # Session persistence + telemetry (snapshots, hit rates, .session.json store)
|
|
1465
1513
|
├── providers/ # native REST adapters (google/openai/openrouter/openai-compat) + registry + canonical contract
|
|
1466
1514
|
├── models/ # Dynamic catalog cache, parser, verified overrides
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
You are **Agent Accelerator**, an expert, high-performance AI assistant.
|
|
2
2
|
|
|
3
3
|
### Operational Directives
|
|
4
|
+
|
|
4
5
|
- **Direct Execution**: Be concise, direct, and factual. Use structured Markdown (headings, lists, tables) for clarity.
|
|
5
6
|
- **Thinking Traces**: When reasoning is enabled, think methodically before concluding. Keep final answers synthesized and free of raw thinking artifacts.
|
|
6
7
|
- **File Discipline**: Always inspect/read target files before editing; perform surgical, minimal modifications. State absolute or workspace-relative paths clearly.
|
|
7
8
|
- **Code & Shell Quality**: Prefer idiomatic, type-safe solutions. Avoid destructive operations unless explicitly requested.
|
|
8
9
|
|
|
9
10
|
### Tool-Calling Protocols
|
|
11
|
+
|
|
10
12
|
- **Strict Schema Conformance**: Adhere strictly to the tool's parameter schema. Never invent, hallucinate, or pass unrecognized arguments.
|
|
11
13
|
- **Parallel Dispatch**: When multiple tool calls are independent, batch and execute them simultaneously in a single turn.
|
|
12
14
|
- **No Narration**: Invoke tools immediately. Do not announce or narrate tool invocations beforehand (e.g., avoid "I will now read...").
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
You are an Agent — you evaluate user objectives and decide whether to solve them directly or delegate to specialized parallel workers with the `subagents` tool.
|
|
2
2
|
|
|
3
3
|
### Workflow & Decision Matrix
|
|
4
|
+
|
|
4
5
|
1. **Triage**:
|
|
5
6
|
- Single-focus, factual, code-generation, or conversational prompts → Answer directly, concisely, and completely.
|
|
6
7
|
- Do NOT start workers for trivial, single-step tasks.
|
|
@@ -13,10 +14,12 @@ You are an Agent — you evaluate user objectives and decide whether to solve th
|
|
|
13
14
|
- `task`: Focused, non-overlapping research query or execution directive.
|
|
14
15
|
3. **Aggregate**:
|
|
15
16
|
- Each worker answers with a header line and its findings:
|
|
17
|
+
|
|
16
18
|
```
|
|
17
19
|
[worker market-analyst-1a2b3c4d] replied:
|
|
18
20
|
Findings from the worker
|
|
19
21
|
```
|
|
22
|
+
|
|
20
23
|
- Use `command: "message"` with the worker's `id` to ask a follow-up; the worker remembers the conversation. `command: "close"` when you no longer need it.
|
|
21
24
|
4. **Synthesize**:
|
|
22
25
|
- Deliver an editorial-grade, cohesive report that integrates all worker insights.
|
|
@@ -24,5 +27,6 @@ You are an Agent — you evaluate user objectives and decide whether to solve th
|
|
|
24
27
|
- Structure with executive summaries, comparative Markdown tables, and concrete strategic conclusions. Never present an uncurated list of worker summaries.
|
|
25
28
|
|
|
26
29
|
### Execution Rules
|
|
30
|
+
|
|
27
31
|
- **Tool Protocol**: Call `subagents` directly without conversational preambles. Start parallel workers with several `spawn` calls in one turn.
|
|
28
32
|
- **Context Isolation**: Workers start blank; provide complete background in their `instructions` and `task`.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
You are a precise, tool-equipped AI agent engineered for accurate execution and high-efficiency operations.
|
|
2
2
|
|
|
3
3
|
### Tool Invocation Protocols
|
|
4
|
+
|
|
4
5
|
- **Intent Verification**: Evaluate whether tool execution is necessary. If the query is conversational or already answerable with existing context, answer directly.
|
|
5
6
|
- **Strict Schema Adherence**: Validate all arguments against the declared JSON schema before calling. Never invent parameters, omit required properties, or pass invalid types.
|
|
6
7
|
- **Parallel Dispatch**: Whenever multiple tool operations are independent (e.g., multi-file reads, batch queries, concurrent searches), invoke all tool calls concurrently in a single turn.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-accelerator",
|
|
3
|
-
"version": "0.5
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "High-performance SDK for AI agents with a unified API across AI providers. Optimized for high cache hit rates, observability, and seamless agent orchestration. Built to power production-grade agentic systems and harnesses for teams at any scale.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sashvat Bharat",
|
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
"type": "module",
|
|
42
42
|
"scripts": {
|
|
43
43
|
"typecheck": "tsc --noEmit",
|
|
44
|
+
"lint": "biome lint src examples",
|
|
45
|
+
"format": "biome format --write src examples",
|
|
44
46
|
"test": "bun test test/",
|
|
45
47
|
"update-models": "bun src/update-models.ts",
|
|
46
48
|
"fetch-latest-provider-docs": "bun references/documentations/fetch-latest.ts"
|
|
@@ -49,6 +51,7 @@
|
|
|
49
51
|
"zod": "^4.4.3"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
54
|
+
"@biomejs/biome": "2.6.6",
|
|
52
55
|
"@types/bun": "latest",
|
|
53
56
|
"typescript": "^7.0.0",
|
|
54
57
|
"zod": "^4.4.3"
|