@andreprado/agentkit 0.1.0-alpha.17 → 0.1.0-alpha.19
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 +3 -0
- package/docs/guides/add-channel.md +14 -8
- package/docs/guides/add-knowledge.md +10 -0
- package/docs/guides/add-managed-composio.md +43 -17
- package/docs/guides/channel-security.md +60 -39
- package/docs/guides/connect-discord.md +178 -0
- package/docs/guides/create-agent.md +13 -0
- package/docs/guides/debug-channel.md +147 -0
- package/docs/guides/improve-from-production.md +151 -0
- package/docs/guides/prepare-deploy.md +30 -14
- package/docs/guides/replay-production-traces.md +72 -0
- package/docs/guides/run-evals.md +18 -0
- package/docs/guides/security-rules.md +5 -5
- package/docs/guides/use-provider.md +11 -1
- package/docs/llms-full.txt +106 -15
- package/docs/llms.txt +22 -4
- package/package.json +1 -3
- package/src/cli/args.ts +23 -2
- package/src/cli/cloud-client.ts +75 -0
- package/src/cli/commands/channels.ts +139 -14
- package/src/cli/deploy-chat-ui.ts +146 -3
- package/src/cli/deploy-readiness.ts +57 -1
- package/src/cli/help.ts +32 -8
- package/src/cli/index.ts +447 -17
- package/src/create-project.ts +13 -2
- package/src/index.ts +46 -3
- package/src/providers/pi.ts +49 -15
- package/src/runtime/channel-test-harness.ts +4 -1
- package/src/runtime/channels/discord.ts +887 -0
- package/src/runtime/channels.ts +15 -0
- package/src/runtime/config.ts +39 -3
- package/src/runtime/core/manifest.ts +2 -0
- package/src/runtime/dev-server.ts +149 -8
- package/src/runtime/evals.ts +27 -6
- package/src/runtime/improve.ts +868 -0
- package/src/runtime/inspect.ts +1 -0
- package/src/runtime/integrations/composio.ts +168 -2
- package/src/runtime/knowledge/retrieve.ts +25 -5
- package/src/runtime/knowledge/schema.ts +45 -1
- package/src/runtime/runtime-contract.ts +54 -0
- package/src/runtime/targets/cloudflare/build.ts +479 -194
- package/src/runtime/targets/vps/deploy.ts +1 -1
- package/src/storage/sqlite.ts +7 -2
- package/src/templates/skills/agentkit-capsule/SKILL.md +8 -1
- package/src/templates/skills/agentkit-capsule/references/docs-router.md +1 -2
- package/src/templates/skills/agentkit-channels/SKILL.md +6 -1
- package/src/templates/skills/agentkit-channels/references/channel-debugging.md +2 -1
- package/src/templates/skills/agentkit-channels/references/discord.md +93 -0
- package/src/templates/skills/agentkit-deploy/SKILL.md +6 -0
- package/src/templates/skills/agentkit-evals/SKILL.md +12 -3
- package/src/templates/skills/agentkit-improve/SKILL.md +86 -0
- package/src/templates/skills/agentkit-improve/references/replay-side-effects.md +18 -0
- package/src/templates/skills/agentkit-improve/references/trace-packets.md +22 -0
- package/src/templates/skills/agentkit-improve/templates/regression.eval.md +18 -0
- package/src/templates/skills/agentkit-integrations/SKILL.md +12 -2
- package/src/templates/skills/agentkit-knowledge/SKILL.md +4 -1
- package/src/templates/skills/agentkit-provider/SKILL.md +4 -1
- package/src/templates/skills/agentkit-security/SKILL.md +3 -2
- package/src/templates/skills/agentkit-troubleshooting/SKILL.md +9 -0
- package/src/templates/support.ts +4 -2
- package/docs/guides/agentkit-skills-architecture.md +0 -472
- package/docs/guides/channels-implementation-map.md +0 -243
- package/docs/guides/channels-production-handoff.md +0 -118
- package/docs/portable-deploy-release-checklist.md +0 -41
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Debug A Channel
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Diagnose website, Telegram, WhatsApp, or Discord channel setup, webhook validation, dedupe, buffering, outbound sends, and delivery failures from the Agent Capsule CLI.
|
|
6
|
+
|
|
7
|
+
## When To Use It
|
|
8
|
+
|
|
9
|
+
Use this when a hosted channel is not responding, a provider is retrying messages, audio transcription is failing, or delivery status does not match the user's expectation.
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
agentkit channels list
|
|
15
|
+
agentkit channels status <name>
|
|
16
|
+
agentkit channels doctor <name>
|
|
17
|
+
agentkit channels test <name> --message "hello"
|
|
18
|
+
agentkit channels test-audio <name> --fixture voice-note
|
|
19
|
+
agentkit transcribe smoke --provider groq
|
|
20
|
+
agentkit channels test <name> --fixture ./fixtures/provider-event.json
|
|
21
|
+
agentkit channels deliveries list <name> --since 24h
|
|
22
|
+
agentkit channels deliveries show <delivery-id>
|
|
23
|
+
agentkit channels buffers list <name>
|
|
24
|
+
agentkit channels buffers show <conversation-id>
|
|
25
|
+
agentkit channels buffers flush <conversation-id>
|
|
26
|
+
agentkit channels buffers clear <conversation-id>
|
|
27
|
+
agentkit channels buffers retry <conversation-id>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Files Created Or Edited
|
|
31
|
+
|
|
32
|
+
Debugging should not require source edits. Use fixtures only when reproducing provider payload shape, and never commit provider secrets, full phone numbers, raw audio, or private client data.
|
|
33
|
+
|
|
34
|
+
## Delivery States
|
|
35
|
+
|
|
36
|
+
```txt
|
|
37
|
+
received
|
|
38
|
+
validated
|
|
39
|
+
duplicate
|
|
40
|
+
audio_received
|
|
41
|
+
audio_downloaded
|
|
42
|
+
transcribing
|
|
43
|
+
transcribed
|
|
44
|
+
buffered
|
|
45
|
+
queued
|
|
46
|
+
running
|
|
47
|
+
agent_completed
|
|
48
|
+
provider_request_built
|
|
49
|
+
provider_sent
|
|
50
|
+
adapter_stubbed
|
|
51
|
+
delivered
|
|
52
|
+
provider_failed
|
|
53
|
+
failed
|
|
54
|
+
dead_lettered
|
|
55
|
+
skipped
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Minimal Working Example
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
agentkit channels test support-telegram --message "hello"
|
|
62
|
+
agentkit channels deliveries list support-telegram --since 1h
|
|
63
|
+
agentkit channels deliveries show del_123
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Expected `show` output includes signature status, dedupe key, queue/run state, outbound provider request ID when available, and a normalized error envelope.
|
|
67
|
+
|
|
68
|
+
## Safety Rules
|
|
69
|
+
|
|
70
|
+
- Inspect delivery IDs, hashes, statuses, and redacted metadata rather than raw provider payloads.
|
|
71
|
+
- Never paste provider secrets into fixtures or prompts.
|
|
72
|
+
- Treat `adapter_stubbed` as a dry-run send, not proof that a client received a message.
|
|
73
|
+
- Before replaying or flushing buffered conversations, confirm the channel name and conversation ID.
|
|
74
|
+
- Keep local `.env` values ignored and upload hosted production values through AgentKit secret commands.
|
|
75
|
+
|
|
76
|
+
## Troubleshooting By Error Code
|
|
77
|
+
|
|
78
|
+
`channel_not_found`:
|
|
79
|
+
The webhook URL points to an unknown or deleted channel. Stable hosted URLs use the channel name, for example `/channels/support-whatsapp/whatsapp/zapster/webhook`; old `chn_*` URLs are accepted only for compatibility.
|
|
80
|
+
|
|
81
|
+
`agentkit channels test <name>` is the official synthetic smoke. If it fails while `channels list`, `status`, or `doctor` find the channel, rerun against the current deploy state in `.agentkit/deploy.json`.
|
|
82
|
+
|
|
83
|
+
`channel_disabled`:
|
|
84
|
+
The channel was disabled. Re-add or recreate it.
|
|
85
|
+
|
|
86
|
+
`channel_secret_missing`:
|
|
87
|
+
The hosted secret metadata says a required channel secret is missing. Set it with `agentkit secret set <NAME> --from-local-env` or `agentkit secret sync --from-local`.
|
|
88
|
+
|
|
89
|
+
`channel_signature_invalid`:
|
|
90
|
+
Provider authenticity validation failed. Check the provider webhook secret, token, origin settings, or Discord public key.
|
|
91
|
+
|
|
92
|
+
`channel_payload_invalid`:
|
|
93
|
+
The provider payload is malformed or does not match the route provider.
|
|
94
|
+
|
|
95
|
+
Discord endpoint validation fails in the Developer Portal:
|
|
96
|
+
Confirm `DISCORD_PUBLIC_KEY` is set from the application's public key and the webhook URL is `/channels/<name>/discord/discord/webhook`. AgentKit must validate Discord's signature headers before returning the `PING` PONG.
|
|
97
|
+
|
|
98
|
+
Discord bot does not answer normal server messages:
|
|
99
|
+
Confirm the channel was created with `--mode bot`, `DISCORD_BOT_TOKEN` is set, Message Content Intent is enabled in the Discord Developer Portal, the app is installed into the server, and the bot has `View Channel`, `Read Message History`, and `Send Messages` permissions for the channel.
|
|
100
|
+
|
|
101
|
+
`audio_received`:
|
|
102
|
+
The webhook contained a supported audio message and the channel is entering the audio handling path.
|
|
103
|
+
|
|
104
|
+
`audio_downloaded`:
|
|
105
|
+
The retryable channel worker downloaded the provider media file into memory. The delivery metadata should include only redacted size, MIME, and provider IDs.
|
|
106
|
+
|
|
107
|
+
`transcribing`:
|
|
108
|
+
AgentKit is calling the configured transcription provider with the user's managed transcription secret.
|
|
109
|
+
|
|
110
|
+
`transcribed`:
|
|
111
|
+
Transcription succeeded and the queued agent message contains transcript text instead of raw audio.
|
|
112
|
+
|
|
113
|
+
`channel_event_duplicate` or `duplicate`:
|
|
114
|
+
The provider retried an already-processed event. No second agent run should be created.
|
|
115
|
+
|
|
116
|
+
`buffered`:
|
|
117
|
+
The message is accepted and waiting inside a per-conversation channel buffer. It should move to `queued` after the quiet window, max wait, max message count, or max character count.
|
|
118
|
+
|
|
119
|
+
`adapter_stubbed`:
|
|
120
|
+
The adapter built the outbound request in explicit dry-run mode. The provider was not called.
|
|
121
|
+
|
|
122
|
+
`provider_sent`:
|
|
123
|
+
The provider API accepted the outbound request and returned a provider message ID.
|
|
124
|
+
|
|
125
|
+
`channel_limit_exceeded`:
|
|
126
|
+
Backpressure skipped the message before queueing.
|
|
127
|
+
|
|
128
|
+
`channel_audio_download_unavailable`:
|
|
129
|
+
The channel provider reported audio but did not include enough metadata for AgentKit to download it.
|
|
130
|
+
|
|
131
|
+
`transcription_secret_missing`:
|
|
132
|
+
The transcription provider secret declared in `agentkit inspect` is not set as a managed hosted secret.
|
|
133
|
+
|
|
134
|
+
`transcription_audio_too_large` or `transcription_audio_too_long`:
|
|
135
|
+
The audio exceeded `transcription.limits` or the channel-level `audio.limits`.
|
|
136
|
+
|
|
137
|
+
`transcription_audio_format_unsupported`:
|
|
138
|
+
The configured transcription provider does not accept this audio MIME type or file extension.
|
|
139
|
+
|
|
140
|
+
`transcription_provider_unavailable`:
|
|
141
|
+
The transcription provider returned a retryable error, usually HTTP 429 or a server-side failure.
|
|
142
|
+
|
|
143
|
+
`channel_provider_unavailable`:
|
|
144
|
+
The agent run or provider send path failed with a retryable provider condition.
|
|
145
|
+
|
|
146
|
+
`channel_delivery_dead_lettered`:
|
|
147
|
+
The queue exhausted retries. Inspect the delivery and replay manually only after fixing the cause.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Improve From Production
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Pull hosted or local conversation evidence into the Agent Capsule, turn it into regression evals, let the local coding agent patch the capsule, and replay before deploying again.
|
|
6
|
+
|
|
7
|
+
## When To Use This
|
|
8
|
+
|
|
9
|
+
Use this when a deployed agent gave a wrong answer, failed a tool call, mishandled a channel message, or needs production behavior converted into eval coverage.
|
|
10
|
+
|
|
11
|
+
AgentKit Cloud only exports redacted evidence. The local coding agent owns source edits, evals, replay, and deploy.
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
Collect evidence from the last hosted deploy:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
agentkit improve collect --deploy --since 24h
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
When the CLI is logged in to AgentKit Cloud, this command first asks the control plane for deploy evidence such as failed channel deliveries, deploy errors, and conversation IDs that need review. It then reads replayable hosted conversation traces from the deployed runtime with the deploy access token. If Cloud auth is not available, it still collects hosted conversations directly from the deploy URL.
|
|
22
|
+
|
|
23
|
+
Hosted conversation reads require a deploy access token even when the chat endpoint is public. `agentkit deploy` normally writes `.agentkit/chat-access-token.json`; refresh it with:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
agentkit access token create agentkit-chat-ui --out .agentkit/chat-access-token.json
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Collect one hosted conversation:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
agentkit improve collect --deploy --conversation-id <conversation-id>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Collect local conversations instead:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
agentkit improve collect --since 7d
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Generate regression evals from the collected bundle:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
agentkit improve evals .agentkit/improve/<run>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Replay the bundle against the local capsule:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
agentkit replay .agentkit/improve/<run> --against local
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Files Created Or Edited
|
|
54
|
+
|
|
55
|
+
Evidence bundle, ignored local state:
|
|
56
|
+
|
|
57
|
+
```txt
|
|
58
|
+
.agentkit/improve/<run>/
|
|
59
|
+
bundle.json
|
|
60
|
+
report.json
|
|
61
|
+
traces/
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Generated regression evals, committed source:
|
|
65
|
+
|
|
66
|
+
```txt
|
|
67
|
+
evals/regressions/
|
|
68
|
+
improve-<conversation>.eval.ts
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The local coding agent may then edit:
|
|
72
|
+
|
|
73
|
+
```txt
|
|
74
|
+
prompts/instructions.md
|
|
75
|
+
agentkit.config.ts
|
|
76
|
+
tools/
|
|
77
|
+
knowledge/
|
|
78
|
+
evals/
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Do not edit `.agentkit/improve/<run>/bundle.json` by hand.
|
|
82
|
+
|
|
83
|
+
## Workflow
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
agentkit improve collect --deploy --since 24h
|
|
87
|
+
agentkit improve evals .agentkit/improve/<run>
|
|
88
|
+
agentkit replay .agentkit/improve/<run> --against local
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Then let the local coding agent inspect `report.json`, the generated eval files, prompts, tools, and Knowledge sources. After edits:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
npm run typecheck
|
|
95
|
+
npm run agentkit -- inspect
|
|
96
|
+
npm run eval
|
|
97
|
+
agentkit replay .agentkit/improve/<run> --against local
|
|
98
|
+
agentkit deploy --smoke "hello"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Safety Rules
|
|
102
|
+
|
|
103
|
+
- Do not paste secrets into evals, prompts, Knowledge files, or reports.
|
|
104
|
+
- Keep `.agentkit/improve/` out of commits.
|
|
105
|
+
- Review generated eval assertions before committing them. AgentKit redacts common email, phone, bearer token, and key patterns in generated eval text, but the local coding agent must still remove or generalize domain-specific client PII.
|
|
106
|
+
- For write, delete, payment, email, or customer-system tools, branch inside the tool on `ctx.runtime.environment === "eval"` and return deterministic non-destructive output.
|
|
107
|
+
- Treat hosted traces as customer evidence.
|
|
108
|
+
- If replay uses a real provider instead of `test/fake`, tell the owner because it may cost money and may be nondeterministic.
|
|
109
|
+
|
|
110
|
+
## Verification
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
npm run typecheck
|
|
114
|
+
npm run agentkit -- inspect
|
|
115
|
+
npm run eval
|
|
116
|
+
agentkit replay .agentkit/improve/<run> --against local
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Expected:
|
|
120
|
+
|
|
121
|
+
- `improve collect` writes a bundle and report under `.agentkit/improve/`.
|
|
122
|
+
- Hosted collection includes a redacted `evidence` summary in `bundle.json` and `report.json` when AgentKit Cloud evidence export is available.
|
|
123
|
+
- `improve evals` writes eval files under `evals/regressions/`.
|
|
124
|
+
- `replay` reports passed, failed, and skipped traces.
|
|
125
|
+
- No production secret values appear in generated files.
|
|
126
|
+
|
|
127
|
+
## Troubleshooting
|
|
128
|
+
|
|
129
|
+
`No .agentkit/deploy.json found`:
|
|
130
|
+
|
|
131
|
+
Run `agentkit deploy` first, or collect local evidence without `--deploy`.
|
|
132
|
+
|
|
133
|
+
`deploy_conversation_request_failed`:
|
|
134
|
+
|
|
135
|
+
Refresh the deploy chat token with `agentkit access token create agentkit-chat-ui --out .agentkit/chat-access-token.json`, then retry.
|
|
136
|
+
|
|
137
|
+
`improve_evidence_store_not_configured`:
|
|
138
|
+
|
|
139
|
+
The Cloud API does not expose deploy evidence export yet. The CLI falls back to hosted conversation trace collection when possible.
|
|
140
|
+
|
|
141
|
+
`conversation_access_not_configured`:
|
|
142
|
+
|
|
143
|
+
The hosted runtime is not configured with a deploy access-token gate for conversation reads. Redeploy through AgentKit Cloud so the runtime gate is injected, or configure an explicit deploy/private token for local hosted testing.
|
|
144
|
+
|
|
145
|
+
`trace has no user turns`:
|
|
146
|
+
|
|
147
|
+
The trace cannot become a useful conversation eval. Keep the report for diagnosis, but do not commit an empty eval.
|
|
148
|
+
|
|
149
|
+
Generated eval is too strict:
|
|
150
|
+
|
|
151
|
+
Edit the eval to assert the important behavior, such as tool input, safety wording, or knowledge source usage, instead of exact prose.
|
|
@@ -25,7 +25,18 @@ npm run agentkit -- db migrate
|
|
|
25
25
|
npm run chat -- --message "hello"
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
All scaffold, local dev, chat, eval, inspect, database, and build commands are token-free.
|
|
28
|
+
All scaffold, local dev, chat, eval, inspect, database, and build commands are token-free. Hosted production deploy and hosted AgentKit Cloud changes require an AgentKit Cloud account token with hosted deploy access.
|
|
29
|
+
|
|
30
|
+
If the user does not have a token yet, start checkout from the CLI, finish Stripe Checkout in the browser, then claim the one-time checkout intent:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npm run agentkit -- billing checkout --slots 1 --email user@example.com
|
|
34
|
+
npm run agentkit -- billing claim billint_... --secret bsec_...
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The claim command stores the returned `agk_user_...` token in the local AgentKit Cloud auth file. Treat the `bsec_...` checkout secret like a password; it exists only to claim the first token after checkout.
|
|
38
|
+
|
|
39
|
+
If the user already has a token:
|
|
29
40
|
|
|
30
41
|
```sh
|
|
31
42
|
npm run agentkit -- login --token agk_user_...
|
|
@@ -42,7 +53,15 @@ OPENAI_API_KEY=sk-...
|
|
|
42
53
|
```
|
|
43
54
|
|
|
44
55
|
`.env` is local-only. Hosted deploy secrets are handled by AgentKit outside the capsule.
|
|
45
|
-
|
|
56
|
+
Hosted deploys require an account with either `cloudflare_deploy_alpha` or purchased/manual deploy slots. Deploy slots belong to the account, not to a specific token string.
|
|
57
|
+
|
|
58
|
+
To generate or switch account tokens after login:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
npm run agentkit -- account token create new-laptop --use
|
|
62
|
+
npm run agentkit -- account token list
|
|
63
|
+
npm run agentkit -- account token revoke apitok_...
|
|
64
|
+
```
|
|
46
65
|
|
|
47
66
|
## What The Agent Should Edit
|
|
48
67
|
|
|
@@ -126,6 +145,7 @@ For a final end-to-end test, run:
|
|
|
126
145
|
|
|
127
146
|
```sh
|
|
128
147
|
npm run agentkit -- login --token agk_user_...
|
|
148
|
+
npm run agentkit -- account token list
|
|
129
149
|
npm run agentkit -- secret sync --from-local
|
|
130
150
|
npm run agentkit -- secret list
|
|
131
151
|
npm run agentkit -- deploy --smoke "hello"
|
|
@@ -134,7 +154,7 @@ npm run agentkit -- chat-ui --deploy
|
|
|
134
154
|
npm run agentkit -- access token list
|
|
135
155
|
```
|
|
136
156
|
|
|
137
|
-
For
|
|
157
|
+
For hosted deploys, `npm run agentkit -- deploy` writes the local chat/UI access token to `.agentkit/chat-access-token.json`. Use `npm run agentkit -- deploy --smoke "hello"` for the official hosted chat smoke, and use `npm run agentkit -- chat-ui --deploy` for hosted UI testing. The hosted Chat UI shows the conversation id, tool calls, tool errors, and a new-conversation control; use `npm run agentkit -- conversations trace <conversation-id> --deploy` to pull the hosted trace from the last deploy. Use `npm run agentkit -- access token create <name> --out <path>` only for additional clients.
|
|
138
158
|
|
|
139
159
|
When the UI is running, open the printed `Chat:` URL and tell the owner the exact URL. If the capsule is still on `test/fake`, say the UI was tested only with the deterministic fake provider.
|
|
140
160
|
|
|
@@ -147,6 +167,7 @@ All required secret names are declared
|
|
|
147
167
|
Prompt path exists
|
|
148
168
|
Tools have input schemas
|
|
149
169
|
Dangerous tools have permissions
|
|
170
|
+
Managed Composio toolkit auth configs are available in AgentKit Cloud when configured
|
|
150
171
|
Provider model is supported by AgentKit
|
|
151
172
|
schema.sql is idempotent
|
|
152
173
|
README/AGENTS/CLAUDE match the capsule
|
|
@@ -172,7 +193,7 @@ echo 'OPENAI_API_KEY=sk-...' >> .env
|
|
|
172
193
|
|
|
173
194
|
Missing hosted secret:
|
|
174
195
|
|
|
175
|
-
Set the secret in AgentKit Cloud
|
|
196
|
+
Set the secret in AgentKit Cloud:
|
|
176
197
|
|
|
177
198
|
```sh
|
|
178
199
|
npm run agentkit -- secret set OPENAI_API_KEY --from-local-env
|
|
@@ -192,20 +213,15 @@ Before a hosted production deploy, run:
|
|
|
192
213
|
npm run agentkit -- deploy doctor
|
|
193
214
|
```
|
|
194
215
|
|
|
195
|
-
The doctor checks AgentKit Cloud login, Node version,
|
|
216
|
+
The doctor checks AgentKit Cloud login, Node version, hosted deploy entitlement, online deploy capacity, declared hosted secrets, local `.env` names that have not been uploaded with `npm run agentkit -- secret set`, and private-access runtime token handling. `agentkit deploy` runs the same readiness check automatically before building and uploading the artifact.
|
|
196
217
|
|
|
197
|
-
If the capsule configures `composioManaged({...})`, the doctor also checks the paid `managed_composio` entitlement. `COMPOSIO_API_KEY`
|
|
218
|
+
If the capsule configures `composioManaged({...})`, the doctor also checks the paid `managed_composio` entitlement and AgentKit Cloud toolkit readiness. `COMPOSIO_API_KEY` and toolkit auth config resolution are AgentKit-managed in this path; the user must not set them with `agentkit secret set`.
|
|
198
219
|
|
|
199
220
|
`alpha_access_required`:
|
|
200
221
|
|
|
201
|
-
Log in with an
|
|
222
|
+
Log in with an account that has hosted deploy access. If the user needs to buy slots first:
|
|
202
223
|
|
|
203
224
|
```sh
|
|
204
|
-
npm run agentkit --
|
|
225
|
+
npm run agentkit -- billing checkout --slots 1 --email user@example.com
|
|
226
|
+
npm run agentkit -- billing claim billint_... --secret bsec_...
|
|
205
227
|
```
|
|
206
|
-
|
|
207
|
-
## Operator Notes
|
|
208
|
-
|
|
209
|
-
This section is for AgentKit maintainers, not for capsule-building agents.
|
|
210
|
-
|
|
211
|
-
`agentkit deploy` sends the capsule artifact to the configured AgentKit Cloud API. The control plane owns infrastructure selection, provisioning, managed secrets, and public URL creation. Use `AGENTKIT_CLOUD_API_URL` only when testing a non-default control plane.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Replay Production Traces
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Run collected production or local traces against the local Agent Capsule before redeploying a fix.
|
|
6
|
+
|
|
7
|
+
## When To Use This
|
|
8
|
+
|
|
9
|
+
Use this after `agentkit improve collect` and before `agentkit deploy` whenever prompts, tools, Knowledge, provider config, or channel behavior changed because of production evidence.
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
agentkit replay .agentkit/improve/<run> --against local
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Run the full local eval suite too:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm run eval
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## What Replay Checks
|
|
24
|
+
|
|
25
|
+
Replay sends each collected user turn through the local capsule in eval mode:
|
|
26
|
+
|
|
27
|
+
```txt
|
|
28
|
+
ctx.runtime.environment === "eval"
|
|
29
|
+
ctx.runtime.invocation === "eval"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This proves the current capsule can process the production turns without runtime errors. Generated eval files under `evals/regressions/` add committed behavior assertions.
|
|
33
|
+
|
|
34
|
+
## Write Tool Safety
|
|
35
|
+
|
|
36
|
+
Replay still runs the registered capsule tools. Any tool that can write externally must guard eval mode:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
if (ctx.runtime.environment === "eval") {
|
|
40
|
+
return { sent: false, evalFixture: true };
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Do not depend on prompt wording alone to prevent side effects.
|
|
45
|
+
|
|
46
|
+
## Deploy Gate
|
|
47
|
+
|
|
48
|
+
Before redeploying a production fix:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
npm run typecheck
|
|
52
|
+
npm run agentkit -- inspect
|
|
53
|
+
npm run eval
|
|
54
|
+
agentkit replay .agentkit/improve/<run> --against local
|
|
55
|
+
agentkit deploy --smoke "hello"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
If replay fails, inspect the failed trace id in `.agentkit/improve/<run>/traces/`, patch the capsule, and rerun replay.
|
|
59
|
+
|
|
60
|
+
## Troubleshooting
|
|
61
|
+
|
|
62
|
+
`Replay failed`:
|
|
63
|
+
|
|
64
|
+
Read the printed error and the matching trace file. Common causes are missing local secrets, unsafe tools that do not branch on eval mode, stale Knowledge sources, or provider differences.
|
|
65
|
+
|
|
66
|
+
`Replay skipped`:
|
|
67
|
+
|
|
68
|
+
The trace had no user message. It may still help diagnose delivery or deploy state, but it cannot be replayed as a conversation.
|
|
69
|
+
|
|
70
|
+
`provider_model_unsupported`:
|
|
71
|
+
|
|
72
|
+
The local provider config does not match the replay environment. Keep deterministic regression replay on `test/fake` unless the owner intentionally selected a real provider.
|
package/docs/guides/run-evals.md
CHANGED
|
@@ -22,6 +22,12 @@ Run evals:
|
|
|
22
22
|
agentkit eval run
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
If the capsule uses npm scripts and Windows PowerShell blocks `npm.ps1`, use:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm.cmd run eval
|
|
29
|
+
```
|
|
30
|
+
|
|
25
31
|
Create an eval from a stored conversation:
|
|
26
32
|
|
|
27
33
|
```sh
|
|
@@ -31,6 +37,15 @@ agentkit eval from-conversation <conversation-id>
|
|
|
31
37
|
agentkit eval run
|
|
32
38
|
```
|
|
33
39
|
|
|
40
|
+
Create evals from hosted or local production evidence:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
agentkit improve collect --deploy --since 24h
|
|
44
|
+
agentkit improve evals .agentkit/improve/<run>
|
|
45
|
+
agentkit replay .agentkit/improve/<run> --against local
|
|
46
|
+
agentkit eval run
|
|
47
|
+
```
|
|
48
|
+
|
|
34
49
|
## Files Created Or Edited
|
|
35
50
|
|
|
36
51
|
Create or edit:
|
|
@@ -43,9 +58,11 @@ Use conversations as source material:
|
|
|
43
58
|
|
|
44
59
|
```txt
|
|
45
60
|
.agentkit/agentkit.db
|
|
61
|
+
.agentkit/improve/<run>/
|
|
46
62
|
```
|
|
47
63
|
|
|
48
64
|
Do not edit `.agentkit/agentkit.db` by hand.
|
|
65
|
+
Do not edit `.agentkit/improve/<run>/bundle.json` by hand.
|
|
49
66
|
|
|
50
67
|
## Minimal Working Example
|
|
51
68
|
|
|
@@ -200,6 +217,7 @@ export const sendFollowupEmail = defineTool({
|
|
|
200
217
|
- Keep eval tool calls deterministic and non-destructive.
|
|
201
218
|
- For tools that would write, delete, charge money, send email, or call a real customer system, branch inside the registered tool on `ctx.runtime.environment === "eval"` and return safe fixture output.
|
|
202
219
|
- Treat conversations as source material, not as automatically safe training data.
|
|
220
|
+
- Review generated regression evals from `agentkit improve evals` before committing them. AgentKit redacts common email, phone, bearer token, and key patterns in generated eval text, but you must still remove or generalize domain-specific client PII and replace brittle exact prose assertions with the important behavior when needed.
|
|
203
221
|
|
|
204
222
|
## Verification
|
|
205
223
|
|
|
@@ -93,14 +93,14 @@ defineTool({
|
|
|
93
93
|
- `.env.schema` is the committed contract for local secret names.
|
|
94
94
|
- AgentKit local commands load `.env` directly so inspect, chat, tools, and evals share the same secret loader.
|
|
95
95
|
- Production uses managed secrets.
|
|
96
|
-
- Hosted
|
|
96
|
+
- Hosted deploys require `cloudflare_deploy_alpha` or purchased/manual deploy slots; local commands do not require login.
|
|
97
97
|
- Secret values must not appear in config, docs, prompts, evals, logs, exports, or SQLite.
|
|
98
98
|
- A tool receives only secrets listed in that tool.
|
|
99
99
|
- Avoid direct `process.env` reads inside tools.
|
|
100
100
|
- Use `permissions` to describe external capabilities.
|
|
101
101
|
- Add timeouts to network tools.
|
|
102
|
-
- Treat
|
|
103
|
-
- Use access tokens and
|
|
102
|
+
- Treat hosted deploy URLs as addresses, not access control.
|
|
103
|
+
- Use deploy access tokens for hosted chat, hosted conversation reads, hosted trace reads, and any client app that talks to AgentKit Cloud.
|
|
104
104
|
- Remove client PII before writing evals.
|
|
105
105
|
|
|
106
106
|
## Verification
|
|
@@ -132,9 +132,9 @@ Add the secret name to the tool `secrets` field and set it locally:
|
|
|
132
132
|
npm run agentkit -- inspect
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
Hosted URL is reachable without a token:
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
Treat this as a security bug. Hosted AgentKit Cloud routes should reject missing deploy tokens except authenticated channel webhook ingress.
|
|
138
138
|
|
|
139
139
|
## Backend Contracts Used
|
|
140
140
|
|
|
@@ -21,6 +21,14 @@ npm run chat -- --message "hello"
|
|
|
21
21
|
npm run agentkit -- inspect
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
On Windows PowerShell, if `npm.ps1` is blocked by `PSSecurityException`, use the Windows command shim:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm.cmd run typecheck
|
|
28
|
+
npm.cmd run chat -- --message "hello"
|
|
29
|
+
npm.cmd run agentkit -- inspect
|
|
30
|
+
```
|
|
31
|
+
|
|
24
32
|
## Files Created Or Edited
|
|
25
33
|
|
|
26
34
|
Edit:
|
|
@@ -77,6 +85,8 @@ provider: {
|
|
|
77
85
|
secrets: ["OPENROUTER_API_KEY"],
|
|
78
86
|
```
|
|
79
87
|
|
|
88
|
+
Prefer model ids or aliases listed by the installed Pi SDK when available, such as `~google/gemini-flash-latest`. If an OpenRouter model id is newer than the Pi model registry, AgentKit passes the id through to OpenRouter using Pi's OpenAI-compatible transport with conservative unknown-model metadata. The provider may still reject the request if the id is invalid, inaccessible, or does not support the tools/features the agent uses.
|
|
89
|
+
|
|
80
90
|
## UI Verification
|
|
81
91
|
|
|
82
92
|
After the provider is configured and the local secret is set, test through chat and UI:
|
|
@@ -125,7 +135,7 @@ npm run agentkit -- inspect
|
|
|
125
135
|
|
|
126
136
|
`provider_model_unsupported`:
|
|
127
137
|
|
|
128
|
-
|
|
138
|
+
For OpenAI or Anthropic, use a model id known to the installed Pi SDK for that provider. For OpenRouter, prefer a known Pi alias when possible; otherwise a raw OpenRouter model id is passed through and any remaining model error comes from OpenRouter.
|
|
129
139
|
|
|
130
140
|
Provider returns auth failure:
|
|
131
141
|
|