@inneranimalmedia/agentsam-sdk 2.5.0 → 2.6.1
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/AGENTSAM.md +55 -0
- package/README.md +12 -8
- package/bin/agentsam +2 -0
- package/docs/AGENTSAM_ASTRA_OPENAI_INTEGRATION.md +1363 -0
- package/docs/CLI_SHELL.md +163 -53
- package/docs/PLATFORM_RUNTIME_EVENTS.md +48 -0
- package/docs/RELEASES.md +16 -7
- package/docs/SOURCE_ARCHITECTURE.md +58 -0
- package/docs/TEST_TIERS.md +26 -0
- package/migrations/runtime/0001_cli_runtime.sql +298 -0
- package/package.json +45 -12
- package/packages/agentsam-repository/README.md +15 -0
- package/packages/agentsam-repository/package.json +25 -0
- package/packages/agentsam-repository/src/contracts.js +113 -0
- package/packages/agentsam-repository/src/index.js +3 -0
- package/{src/lib → packages/agentsam-repository/src}/merkle/cloudflare-persistence.js +14 -24
- package/{src/lib → packages/agentsam-repository/src}/merkle/index.js +1 -0
- package/{src/lib → packages/agentsam-repository/src}/merkle/persistence.js +6 -4
- package/{src/lib → packages/agentsam-repository/src}/merkle/policy.js +1 -0
- package/packages/agentsam-repository/test/contracts.test.mjs +40 -0
- package/packages/agentsam-repository/test/git-context.test.mjs +24 -0
- package/{test/merkle.test.mjs → packages/agentsam-repository/test/merkle-core.test.mjs} +2 -32
- package/{test → packages/agentsam-repository/test}/merkle-persistence.test.mjs +11 -6
- package/packages/connectors/cloudflare/package.json +10 -0
- package/packages/connectors/cloudflare/src/index.js +127 -0
- package/packages/connectors/cloudflare/src/owner.js +76 -0
- package/packages/connectors/cloudflare/src/routes.js +223 -0
- package/packages/connectors/cloudflare/src/vault.js +80 -0
- package/packages/connectors/cloudflare/tests/connector.test.mjs +44 -0
- package/packages/identity/package.json +2 -2
- package/packages/identity/src/contracts/auth-config.js +18 -7
- package/packages/identity/tests/auth-config.test.mjs +9 -5
- package/packages/identity/tests/oauth-credentials.test.mjs +4 -4
- package/protocol/COMPANY_REPOSITORY_GRAPH_V1.md +91 -0
- package/protocol/MERKLE_PERSISTENCE_V1.md +2 -0
- package/protocol/MERKLE_PERSISTENCE_V2.md +40 -0
- package/protocol/README.md +1 -0
- package/protocol/capabilities/cloudflare-cpu-audit-input.schema.json +19 -0
- package/protocol/capabilities/cloudflare-cpu-profile-input.schema.json +13 -0
- package/protocol/capabilities/cloudflare-wrangler-native-input.schema.json +19 -0
- package/protocol/capabilities/manifest.json +47 -0
- package/protocol/context/context-budget.schema.json +10 -15
- package/protocol/context/context-item.schema.json +4 -5
- package/protocol/context/resolved-context-pack.schema.json +19 -14
- package/protocol/models/README.md +373 -0
- package/protocol/models/model-inventory-v2.schema.json +212 -0
- package/protocol/repository/repository-contract.schema.json +24 -0
- package/protocol/repository/repository-dependency.schema.json +24 -0
- package/protocol/repository/repository-identity.schema.json +17 -0
- package/protocol/rpc/v1/common.proto +16 -0
- package/protocol/rpc/v1/errors.proto +35 -0
- package/protocol/rpc/v1/knowledge.proto +77 -0
- package/services/knowledge/package-lock.json +333 -0
- package/services/knowledge/package.json +5 -1
- package/skills/agentsam-cloudflare-workers/SKILL.md +53 -0
- package/skills/agentsam-cloudflare-workers/references/cpu-profiling.md +16 -0
- package/skills/agentsam-cloudflare-workers/references/errors-and-observability.md +29 -0
- package/skills/agentsam-cloudflare-workers/references/wrangler-native-map.md +28 -0
- package/skills/catalog.json +18 -0
- package/src/agent/capability-adapter.js +25 -13
- package/src/agent/index.js +1 -0
- package/src/agent/responses-runner.js +353 -0
- package/src/capabilities/repository-snapshot.js +3 -3
- package/src/cli.js +118 -31
- package/src/cloudflare/cpu-profile.js +115 -0
- package/src/cloudflare/index.js +14 -0
- package/src/cloudflare/wrangler.js +132 -0
- package/src/commands/account-auth.js +47 -0
- package/src/commands/cloudflare.js +58 -0
- package/src/commands/connections.js +93 -0
- package/src/commands/context-economics.js +129 -0
- package/src/commands/context.js +1 -1
- package/src/commands/db.js +20 -3
- package/src/commands/deploy.js +39 -3
- package/src/commands/env.js +90 -0
- package/src/commands/eval.js +63 -0
- package/src/commands/interactive.js +2 -5
- package/src/commands/knowledge.js +12 -4
- package/src/commands/merkle-persist.js +30 -11
- package/src/commands/merkle.js +1 -1
- package/src/commands/models.js +149 -46
- package/src/commands/ollama.js +26 -0
- package/src/commands/preferences.js +130 -61
- package/src/commands/resume.js +67 -0
- package/src/commands/security.js +5 -3
- package/src/commands/shell.js +568 -119
- package/src/commands/tunnel.js +2 -2
- package/src/commands/whoami.js +86 -0
- package/src/context/budget.js +68 -6
- package/src/context/index.js +3 -1
- package/src/context/rehydrate.js +35 -0
- package/src/context/resolve.js +44 -12
- package/src/errors/contract.js +236 -0
- package/src/errors/diagnostic.js +160 -0
- package/src/errors/index.js +23 -0
- package/src/eval/context.js +191 -0
- package/src/eval/index.js +1 -0
- package/src/index.js +68 -2
- package/src/knowledge/service/auth.js +13 -0
- package/src/knowledge/service/grpc-client.js +115 -0
- package/src/knowledge/service/grpc-codec.js +237 -0
- package/src/knowledge/service/grpc-server.js +83 -0
- package/src/knowledge/service/job-engine.js +248 -0
- package/src/knowledge/service/server.js +87 -135
- package/src/knowledge/source.js +1 -1
- package/src/lib/account-session.js +98 -0
- package/src/lib/agent-instructions.js +73 -0
- package/src/lib/auth.js +4 -0
- package/src/lib/cli-preferences.js +55 -24
- package/src/lib/deploy/git-guard.js +69 -0
- package/src/lib/deploy/health.js +57 -0
- package/src/lib/deploy/local-studio.js +283 -0
- package/src/lib/deploy/secret-scan.js +65 -0
- package/src/lib/deploy-receipt/index.js +2 -2
- package/src/lib/detect-context.js +2 -2
- package/src/lib/execution-approvals.js +59 -0
- package/src/lib/knowledge-docker.js +6 -3
- package/src/lib/local-sessions.js +148 -0
- package/src/lib/local-status.js +1 -1
- package/src/lib/project-config.js +1 -1
- package/src/lib/provider-credentials.js +183 -0
- package/src/lib/scaffold/templates/worker-api/index.js +101 -20
- package/src/lib/scaffold/wizards/worker-api.js +27 -11
- package/src/lib/slash-commands.js +23 -16
- package/src/local/migrations.js +93 -0
- package/src/local/runtime-store.js +141 -0
- package/src/local/sqlite.js +2 -0
- package/src/local-pty/server.js +113 -51
- package/src/models/catalog.js +135 -0
- package/src/models/discovery.js +292 -0
- package/src/models/index.js +7 -0
- package/src/providers/anthropic-messages.js +192 -0
- package/src/providers/cloudflare-chat.js +183 -0
- package/src/providers/factory.js +69 -0
- package/src/providers/gemini-generate-content.js +208 -0
- package/src/providers/index.js +10 -0
- package/src/providers/ollama-chat.js +148 -0
- package/src/providers/openai-responses.js +426 -0
- package/src/repository/index.js +14 -2
- package/src/rpc/generated/common_grpc_pb.js +1 -0
- package/src/rpc/generated/common_pb.js +536 -0
- package/src/rpc/generated/errors_grpc_pb.js +1 -0
- package/src/rpc/generated/errors_pb.js +482 -0
- package/src/rpc/generated/knowledge_grpc_pb.js +135 -0
- package/src/rpc/generated/knowledge_pb.js +2168 -0
- package/src/rpc/generated/package.json +3 -0
- package/src/security/process.js +35 -9
- package/src/security/trust-boundary.js +2 -2
- package/src/telemetry/contracts.js +203 -0
- package/src/telemetry/events.js +51 -0
- package/src/telemetry/index.js +8 -0
- package/src/tools/hydrate.js +35 -0
- package/src/tools/index.js +1 -0
- package/src/ui/boot.js +15 -17
- package/src/ui/cli/activity.js +76 -0
- package/src/ui/cli/compaction.js +15 -0
- package/src/ui/cli/footer.js +39 -0
- package/src/ui/cli/help.js +192 -0
- package/src/ui/cli/plan.js +20 -0
- package/src/ui/cli/runtime-events.js +110 -0
- package/src/ui/cli/waiting.js +16 -0
- package/src/ui/merkle/render.js +1 -1
- package/test/account-session.test.mjs +36 -0
- package/test/cli/preferences-runtime.test.mjs +11 -0
- package/test/cli/runtime-ui.test.mjs +74 -0
- package/test/cli-preferences.test.mjs +26 -5
- package/test/cloudflare-connector.test.mjs +96 -0
- package/test/cloudflare-runtime.test.mjs +75 -0
- package/test/context.test.mjs +61 -12
- package/test/deploy-health-scan.test.mjs +67 -0
- package/test/error-diagnostics.test.mjs +115 -0
- package/test/eval-context.test.mjs +37 -0
- package/test/execution-approvals.test.mjs +27 -0
- package/test/fixtures/knowledge-rpc-worker.mjs +16 -0
- package/test/integration/cli-help.test.mjs +37 -0
- package/test/integration/knowledge-rpc.test.mjs +112 -0
- package/test/integration/merkle-cli.test.mjs +61 -0
- package/test/integration/merkle-persistence-identity.test.mjs +48 -0
- package/test/integration/provider-env-cli.test.mjs +49 -0
- package/test/integration/provider-factory.test.mjs +197 -0
- package/test/integration/repository-company-graph.test.mjs +90 -0
- package/test/integration/runtime-migrations.test.mjs +82 -0
- package/test/knowledge-service.test.mjs +5 -0
- package/test/knowledge.test.mjs +16 -0
- package/test/live/terminal-transport.live.test.mjs +24 -0
- package/test/local-sessions.test.mjs +48 -0
- package/test/local-studio-deploy.test.mjs +83 -0
- package/test/model-catalog.test.mjs +43 -0
- package/test/models.test.mjs +127 -16
- package/test/npm10-lock.test.mjs +29 -0
- package/test/ollama.test.mjs +21 -0
- package/test/openai-responses.test.mjs +95 -0
- package/test/portable-context.test.mjs +1 -1
- package/test/provider-credentials.test.mjs +96 -0
- package/test/rehydrate.test.mjs +25 -0
- package/test/release-hygiene.test.mjs +13 -5
- package/test/responses-runner.test.mjs +150 -0
- package/test/shell.test.mjs +92 -23
- package/test/smoke.mjs +4 -1
- package/test/telemetry.test.mjs +79 -0
- package/test/terminal/local-pty.mock.test.mjs +151 -0
- package/test/tools-search.test.mjs +14 -1
- package/test/whoami-resume.test.mjs +56 -0
- /package/{src/lib → packages/agentsam-repository/src}/git-context.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/diff.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/filemeta.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/git-ignore.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/hash.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/semantic.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/snapshot.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/tree.js +0 -0
|
@@ -0,0 +1,1363 @@
|
|
|
1
|
+
# AgentSamAstra — OpenAI Responses API Integration Guide
|
|
2
|
+
|
|
3
|
+
**Status:** implementation baseline
|
|
4
|
+
**Model:** `gpt-6-astra`
|
|
5
|
+
**Canonical OpenAI API:** Responses API
|
|
6
|
+
**Agent instruction contract:** `AGENTSAM.md`
|
|
7
|
+
**Last standardized:** September 12, 2026
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Purpose
|
|
12
|
+
|
|
13
|
+
`AgentSamAstra` is AgentSam's first-class GPT-6 Astra runtime.
|
|
14
|
+
|
|
15
|
+
The goal is not to bolt another model onto the existing provider adapter. Astra should be implemented using the current OpenAI API architecture so that its reasoning, tools, tool discovery, streaming, long-running work, and future steering capabilities are available through one coherent runtime.
|
|
16
|
+
|
|
17
|
+
The central contract is:
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
User
|
|
21
|
+
↓
|
|
22
|
+
AgentSam authenticated runtime
|
|
23
|
+
↓
|
|
24
|
+
AGENTSAM.md + request-specific instructions
|
|
25
|
+
↓
|
|
26
|
+
AgentSam capability/tool registry
|
|
27
|
+
↓
|
|
28
|
+
OpenAI Responses API
|
|
29
|
+
↓
|
|
30
|
+
gpt-6-astra
|
|
31
|
+
↓
|
|
32
|
+
tool calls / reasoning / assistant output
|
|
33
|
+
↓
|
|
34
|
+
AgentSam executes authorized tools
|
|
35
|
+
↓
|
|
36
|
+
function_call_output
|
|
37
|
+
↓
|
|
38
|
+
Responses API continuation
|
|
39
|
+
↓
|
|
40
|
+
final/continuing response
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Do not build a separate Chat Completions tool path for Astra. GPT-6 Astra can appear on Chat Completions for compatible generation use cases, but OpenAI's current guidance explicitly requires the **Responses API for Astra tool calling**.
|
|
44
|
+
|
|
45
|
+
OpenAI currently identifies `gpt-6-astra` as its flagship model for complex end-to-end work, with a 1,050,000-token context window and up to 128,000 output tokens.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
# 2. Core AgentSamAstra laws
|
|
50
|
+
|
|
51
|
+
These should become implementation invariants.
|
|
52
|
+
|
|
53
|
+
### Responses is the canonical runtime
|
|
54
|
+
|
|
55
|
+
All AgentSamAstra turns should enter through one Responses API adapter:
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
provider=openai
|
|
59
|
+
model=gpt-6-astra
|
|
60
|
+
api=responses
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Avoid separate implementations for:
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
simple chat
|
|
67
|
+
tool chat
|
|
68
|
+
coding chat
|
|
69
|
+
reasoning chat
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Those are capabilities and routing decisions inside one provider lane.
|
|
73
|
+
|
|
74
|
+
### AgentSam owns authorization
|
|
75
|
+
|
|
76
|
+
The model may propose an action.
|
|
77
|
+
|
|
78
|
+
It does not decide whether it is authorized.
|
|
79
|
+
|
|
80
|
+
Authentication, account ownership, tool permissions, connection resolution, rate limits, risk checks, filesystem boundaries, and similar enforcement remain application-side concerns.
|
|
81
|
+
|
|
82
|
+
Values the server already knows should generally **not become model-generated tool arguments**. OpenAI similarly recommends removing arguments that application code already possesses rather than forcing the model to regenerate them.
|
|
83
|
+
|
|
84
|
+
For AgentSam specifically:
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
authenticated account
|
|
88
|
+
session/conversation
|
|
89
|
+
resolved repository
|
|
90
|
+
resolved connection
|
|
91
|
+
runtime capability grants
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
should be supplied or derived by the AgentSam runtime.
|
|
95
|
+
|
|
96
|
+
A tool should not ask Astra to invent an `account_id` merely because the backend needs one.
|
|
97
|
+
|
|
98
|
+
### `AGENTSAM.md` defines behavior, not live state
|
|
99
|
+
|
|
100
|
+
`AGENTSAM.md` should contain durable instructions such as:
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
identity
|
|
104
|
+
execution behavior
|
|
105
|
+
tool-use policy
|
|
106
|
+
repository workflow
|
|
107
|
+
testing policy
|
|
108
|
+
communication style
|
|
109
|
+
delegation rules
|
|
110
|
+
approval boundaries
|
|
111
|
+
completion criteria
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
It should not become a dumping ground for dynamic session state, user records, entire repository maps, database contents, or random retrieved context.
|
|
115
|
+
|
|
116
|
+
OpenAI recommends code-managed production prompts with typed dynamic inputs, tests, and normal code review rather than treating remote reusable prompt objects as the application source of truth.
|
|
117
|
+
|
|
118
|
+
That matches the intended AgentSam architecture well:
|
|
119
|
+
|
|
120
|
+
```text
|
|
121
|
+
AGENTSAM.md → stable agent contract
|
|
122
|
+
request input → current user instruction
|
|
123
|
+
capabilities → runtime-resolved tools
|
|
124
|
+
retrieval → explicit task-relevant context
|
|
125
|
+
auth → server-side authority
|
|
126
|
+
conversation → AgentSam session state
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
# 3. `AGENTSAM.md` hierarchy
|
|
132
|
+
|
|
133
|
+
The root instruction file should be concise enough to remain stable and cacheable.
|
|
134
|
+
|
|
135
|
+
Recommended conceptual order:
|
|
136
|
+
|
|
137
|
+
```text
|
|
138
|
+
# AgentSam
|
|
139
|
+
|
|
140
|
+
## Identity
|
|
141
|
+
## User-intent and follow-through
|
|
142
|
+
## Instruction priority
|
|
143
|
+
## Execution rules
|
|
144
|
+
## Tool-use rules
|
|
145
|
+
## Repository and filesystem rules
|
|
146
|
+
## Testing and verification
|
|
147
|
+
## Delegation
|
|
148
|
+
## Communication
|
|
149
|
+
## Completion criteria
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
OpenAI's prompt guidance recommends separating identity, instructions, examples, and contextual information, while keeping reusable prompt material early so prompt caching can benefit from a stable prefix.
|
|
153
|
+
Astra is particularly sensitive to instructions contained in accessible files such as `AGENTS.md`, so conflicting nested instructions and skills need to be audited rather than silently accumulated.
|
|
154
|
+
|
|
155
|
+
Therefore:
|
|
156
|
+
|
|
157
|
+
```text
|
|
158
|
+
AGENTSAM.md
|
|
159
|
+
↓
|
|
160
|
+
feature/repository instructions
|
|
161
|
+
↓
|
|
162
|
+
selected skill instructions
|
|
163
|
+
↓
|
|
164
|
+
task context
|
|
165
|
+
↓
|
|
166
|
+
user request
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
must have an explicit precedence contract.
|
|
170
|
+
|
|
171
|
+
Do not rely on accidental concatenation order.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
# 4. Initial `AGENTSAM.md` behavioral baseline
|
|
176
|
+
|
|
177
|
+
A useful first version is:
|
|
178
|
+
|
|
179
|
+
```md
|
|
180
|
+
# AgentSam
|
|
181
|
+
|
|
182
|
+
## Identity
|
|
183
|
+
|
|
184
|
+
You are AgentSam, an execution-oriented AI software agent.
|
|
185
|
+
|
|
186
|
+
Your job is to understand the user's intended outcome, use available
|
|
187
|
+
capabilities when useful, perform authorized work, verify meaningful
|
|
188
|
+
changes, and continue until the requested task is complete.
|
|
189
|
+
|
|
190
|
+
## Execution
|
|
191
|
+
|
|
192
|
+
Treat requests for action as authorization to perform reversible,
|
|
193
|
+
in-scope work.
|
|
194
|
+
|
|
195
|
+
Infer routine implementation details from the repository, current
|
|
196
|
+
task, available tools, and prior conversation rather than stopping
|
|
197
|
+
for unnecessary clarification.
|
|
198
|
+
|
|
199
|
+
Ask the user only when missing information would materially change
|
|
200
|
+
the result or when an irreversible external action requires approval.
|
|
201
|
+
|
|
202
|
+
Do not stop after describing what should be done when the available
|
|
203
|
+
tools allow you to perform the requested work.
|
|
204
|
+
|
|
205
|
+
## Context
|
|
206
|
+
|
|
207
|
+
Do not assume repository, project, workspace, terminal, browser, or
|
|
208
|
+
other context merely because it exists.
|
|
209
|
+
|
|
210
|
+
Use context explicitly supplied for the current task or deliberately
|
|
211
|
+
retrieve the minimum additional context necessary to complete it.
|
|
212
|
+
|
|
213
|
+
## Tools
|
|
214
|
+
|
|
215
|
+
Use tools when they materially improve correctness or are required to
|
|
216
|
+
perform the requested action.
|
|
217
|
+
|
|
218
|
+
Do not call tools simply because they are available.
|
|
219
|
+
|
|
220
|
+
Prefer the smallest relevant tool surface.
|
|
221
|
+
|
|
222
|
+
If a required tool is deferred, discover it through tool search before
|
|
223
|
+
concluding that the capability is unavailable.
|
|
224
|
+
|
|
225
|
+
Never invent successful tool execution.
|
|
226
|
+
|
|
227
|
+
Use returned tool data as the authority for claims about external
|
|
228
|
+
state.
|
|
229
|
+
|
|
230
|
+
## Authorization
|
|
231
|
+
|
|
232
|
+
Treat runtime authentication and authorization as authoritative.
|
|
233
|
+
|
|
234
|
+
Never invent account IDs, repository IDs, connection IDs, credentials,
|
|
235
|
+
permissions, or ownership information.
|
|
236
|
+
|
|
237
|
+
Do not attempt to bypass capability restrictions enforced by the
|
|
238
|
+
runtime.
|
|
239
|
+
|
|
240
|
+
## Coding
|
|
241
|
+
|
|
242
|
+
Inspect relevant code before making nontrivial changes.
|
|
243
|
+
|
|
244
|
+
Prefer minimal coherent changes that fit the existing architecture.
|
|
245
|
+
|
|
246
|
+
Do not create parallel legacy implementations when an existing
|
|
247
|
+
canonical path can be repaired or extended.
|
|
248
|
+
|
|
249
|
+
## Verification
|
|
250
|
+
|
|
251
|
+
Run checks appropriate to the change.
|
|
252
|
+
|
|
253
|
+
Do not repeatedly execute broad test suites after relevant checks have
|
|
254
|
+
already passed unless new changes or failures justify doing so.
|
|
255
|
+
|
|
256
|
+
Never claim a build, test, migration, merge, deployment, or external
|
|
257
|
+
action succeeded without evidence.
|
|
258
|
+
|
|
259
|
+
## Delegation
|
|
260
|
+
|
|
261
|
+
Delegate parallelizable work when a configured subagent can improve
|
|
262
|
+
speed or quality.
|
|
263
|
+
|
|
264
|
+
The root agent remains responsible for integrating results and
|
|
265
|
+
completing the user's requested outcome.
|
|
266
|
+
|
|
267
|
+
## Communication
|
|
268
|
+
|
|
269
|
+
State the main result clearly.
|
|
270
|
+
|
|
271
|
+
Use concise progress updates during substantial work.
|
|
272
|
+
|
|
273
|
+
Prefer direct technical language over filler, canned conclusions, and
|
|
274
|
+
unnecessary repetition.
|
|
275
|
+
|
|
276
|
+
## Completion
|
|
277
|
+
|
|
278
|
+
Continue until the requested outcome is complete, blocked by a real
|
|
279
|
+
external constraint, or requires an irreversible action for which the
|
|
280
|
+
runtime requires user approval.
|
|
281
|
+
|
|
282
|
+
When blocked, identify the concrete blocker and preserve all completed
|
|
283
|
+
work.
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## This reflects Astra's documented strengths and the areas OpenAI recommends explicitly tuning: follow-through, instruction precedence, writing style, delegation, and proportionate testing.
|
|
287
|
+
|
|
288
|
+
# 5. Canonical Responses request
|
|
289
|
+
|
|
290
|
+
The minimum production request should look conceptually like this:
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
const response = await openai.responses.create({
|
|
294
|
+
model: "gpt-6-astra",
|
|
295
|
+
|
|
296
|
+
reasoning: {
|
|
297
|
+
effort: reasoningEffort,
|
|
298
|
+
},
|
|
299
|
+
|
|
300
|
+
instructions: agentsamInstructions,
|
|
301
|
+
|
|
302
|
+
input,
|
|
303
|
+
|
|
304
|
+
tools,
|
|
305
|
+
|
|
306
|
+
parallel_tool_calls: true,
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Start with the fewest request parameters possible.
|
|
311
|
+
|
|
312
|
+
Do not blindly carry old provider settings into Astra.
|
|
313
|
+
|
|
314
|
+
OpenAI's current Astra migration guidance specifically says to remove unsupported sampling parameters such as:
|
|
315
|
+
|
|
316
|
+
```text
|
|
317
|
+
temperature
|
|
318
|
+
top_p
|
|
319
|
+
top_logprobs
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
when configuring Astra according to the model-specific path.
|
|
323
|
+
|
|
324
|
+
The important behavioral inputs become:
|
|
325
|
+
|
|
326
|
+
```text
|
|
327
|
+
model
|
|
328
|
+
instructions
|
|
329
|
+
input
|
|
330
|
+
reasoning
|
|
331
|
+
tools
|
|
332
|
+
tool_choice
|
|
333
|
+
state/continuation
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
# 6. Reasoning-effort policy
|
|
339
|
+
|
|
340
|
+
GPT-6 Astra supports:
|
|
341
|
+
|
|
342
|
+
```text
|
|
343
|
+
low
|
|
344
|
+
medium
|
|
345
|
+
high
|
|
346
|
+
xhigh
|
|
347
|
+
max
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
It does not support `none`.
|
|
351
|
+
|
|
352
|
+
For the first AgentSamAstra baseline:
|
|
353
|
+
|
|
354
|
+
```text
|
|
355
|
+
ask → low
|
|
356
|
+
plan → medium
|
|
357
|
+
agent → high
|
|
358
|
+
debug → high
|
|
359
|
+
multitask → high
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Use `xhigh` or `max` deliberately for difficult tasks rather than making them the normal default.
|
|
363
|
+
|
|
364
|
+
This should remain a routing configuration value:
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
type AstraReasoningEffort =
|
|
368
|
+
| "low"
|
|
369
|
+
| "medium"
|
|
370
|
+
| "high"
|
|
371
|
+
| "xhigh"
|
|
372
|
+
| "max";
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Do not bury reasoning effort inside the text prompt.
|
|
376
|
+
|
|
377
|
+
Astra can also change reasoning effort during an ongoing conversation through a `configuration_update`, allowing the stable prompt prefix to remain cacheable.
|
|
378
|
+
|
|
379
|
+
That is a Phase 2 optimization, not required for the initial plumbing.
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
# 7. Tool architecture
|
|
384
|
+
|
|
385
|
+
AgentSam should distinguish four tool classes.
|
|
386
|
+
|
|
387
|
+
```text
|
|
388
|
+
1. AgentSam function tools
|
|
389
|
+
AgentSam-owned backend operations
|
|
390
|
+
|
|
391
|
+
2. OpenAI built-in tools
|
|
392
|
+
web search, file search, code interpreter,
|
|
393
|
+
hosted shell, computer use, apply patch, etc.
|
|
394
|
+
|
|
395
|
+
3. MCP tools
|
|
396
|
+
capabilities exposed through MCP servers
|
|
397
|
+
|
|
398
|
+
4. Discovery
|
|
399
|
+
tool_search
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
Function tools are JSON-schema interfaces from Astra into AgentSam-controlled code. Custom tools can accept free-form textual input when structured JSON would be counterproductive. Built-in tools execute through OpenAI's platform. MCP connects other tool systems.
|
|
403
|
+
|
|
404
|
+
These categories should remain distinct in telemetry and permissions even if they share one model-facing registry.
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
# 8. Stop injecting hundreds of tools
|
|
409
|
+
|
|
410
|
+
This is one of the most important architectural changes.
|
|
411
|
+
|
|
412
|
+
OpenAI's current function-calling guidance recommends keeping the initial function surface small, with a soft target of **fewer than 20 functions available at the start of a turn**, and using tool search for larger catalogs.
|
|
413
|
+
|
|
414
|
+
AgentSamAstra should therefore use:
|
|
415
|
+
|
|
416
|
+
```text
|
|
417
|
+
small eager capability surface
|
|
418
|
+
+
|
|
419
|
+
namespaced deferred tools
|
|
420
|
+
+
|
|
421
|
+
tool_search
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
instead of:
|
|
425
|
+
|
|
426
|
+
```text
|
|
427
|
+
200+ schemas
|
|
428
|
+
↓
|
|
429
|
+
every request
|
|
430
|
+
↓
|
|
431
|
+
model must inspect all of them
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Function definitions consume input context and therefore contribute to token usage.
|
|
435
|
+
|
|
436
|
+
A reasonable layout is:
|
|
437
|
+
|
|
438
|
+
```text
|
|
439
|
+
agentsam
|
|
440
|
+
├── repo
|
|
441
|
+
│ ├── inspect
|
|
442
|
+
│ ├── search
|
|
443
|
+
│ └── status
|
|
444
|
+
│
|
|
445
|
+
├── files
|
|
446
|
+
│ ├── read
|
|
447
|
+
│ └── search
|
|
448
|
+
│
|
|
449
|
+
├── terminal
|
|
450
|
+
│ └── status
|
|
451
|
+
│
|
|
452
|
+
├── github
|
|
453
|
+
│ └── status
|
|
454
|
+
│
|
|
455
|
+
└── deferred
|
|
456
|
+
├── deployment/*
|
|
457
|
+
├── database/*
|
|
458
|
+
├── browser/*
|
|
459
|
+
├── advanced_git/*
|
|
460
|
+
├── indexing/*
|
|
461
|
+
├── security/*
|
|
462
|
+
└── specialized MCP tools
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
Exactly which tools are eager should be measured, not guessed.
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
# 9. Namespaces + deferred loading
|
|
470
|
+
|
|
471
|
+
OpenAI now supports namespaces for logically grouping related functions.
|
|
472
|
+
|
|
473
|
+
Example:
|
|
474
|
+
|
|
475
|
+
```ts
|
|
476
|
+
{
|
|
477
|
+
type: "namespace",
|
|
478
|
+
name: "repository",
|
|
479
|
+
description: "Repository inspection and source-control operations.",
|
|
480
|
+
tools: [
|
|
481
|
+
{
|
|
482
|
+
type: "function",
|
|
483
|
+
name: "search",
|
|
484
|
+
...
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
type: "function",
|
|
488
|
+
name: "create_worktree",
|
|
489
|
+
defer_loading: true,
|
|
490
|
+
...
|
|
491
|
+
}
|
|
492
|
+
]
|
|
493
|
+
}
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
A namespace may contain both eager and deferred functions. Deferred functions are discovered through `tool_search`; non-deferred functions remain directly callable.
|
|
497
|
+
|
|
498
|
+
The root request then includes discovery:
|
|
499
|
+
|
|
500
|
+
```ts
|
|
501
|
+
tools: [
|
|
502
|
+
{
|
|
503
|
+
type: "tool_search",
|
|
504
|
+
},
|
|
505
|
+
|
|
506
|
+
...toolNamespaces
|
|
507
|
+
]
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
OpenAI describes hosted tool search as the simple choice when the application already knows the overall inventory and wants the API/model to load only the relevant definitions.
|
|
511
|
+
|
|
512
|
+
This maps naturally onto AgentSam's registry.
|
|
513
|
+
|
|
514
|
+
The registry knows all tools.
|
|
515
|
+
|
|
516
|
+
Astra does not need all schemas in context simultaneously.
|
|
517
|
+
|
|
518
|
+
---
|
|
519
|
+
|
|
520
|
+
# 10. Strict function schemas
|
|
521
|
+
|
|
522
|
+
AgentSam function tools should use:
|
|
523
|
+
|
|
524
|
+
```json
|
|
525
|
+
{
|
|
526
|
+
"strict": true
|
|
527
|
+
}
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
wherever possible.
|
|
531
|
+
|
|
532
|
+
OpenAI currently recommends strict mode because it makes model-generated arguments conform reliably to the declared schema. Strict schemas require object schemas to reject additional properties and to mark declared properties as required.
|
|
533
|
+
|
|
534
|
+
Canonical shape:
|
|
535
|
+
|
|
536
|
+
```ts
|
|
537
|
+
{
|
|
538
|
+
type: "function",
|
|
539
|
+
name: "repository_read_file",
|
|
540
|
+
description: "Read a UTF-8 source file from the resolved repository.",
|
|
541
|
+
strict: true,
|
|
542
|
+
|
|
543
|
+
parameters: {
|
|
544
|
+
type: "object",
|
|
545
|
+
|
|
546
|
+
properties: {
|
|
547
|
+
path: {
|
|
548
|
+
type: "string",
|
|
549
|
+
description: "Repository-relative path to read."
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
|
|
553
|
+
required: ["path"],
|
|
554
|
+
additionalProperties: false
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
If something is optional under strict mode, represent that in the schema itself rather than leaving an undeclared ambiguity.
|
|
560
|
+
|
|
561
|
+
Avoid schemas like:
|
|
562
|
+
|
|
563
|
+
```text
|
|
564
|
+
on: boolean
|
|
565
|
+
off: boolean
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
when one enum could prevent contradictory states.
|
|
569
|
+
|
|
570
|
+
---
|
|
571
|
+
|
|
572
|
+
# 11. The canonical tool loop
|
|
573
|
+
|
|
574
|
+
Never assume:
|
|
575
|
+
|
|
576
|
+
```ts
|
|
577
|
+
response.output[0].content[0].text
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
contains the final answer.
|
|
581
|
+
|
|
582
|
+
OpenAI explicitly warns that `output` can contain multiple kinds of items, including tool and reasoning items, and recommends using `output_text` when the SDK provides it for aggregated assistant text.
|
|
583
|
+
|
|
584
|
+
AgentSam's loop should inspect every output item.
|
|
585
|
+
|
|
586
|
+
Conceptually:
|
|
587
|
+
|
|
588
|
+
```ts
|
|
589
|
+
let input = initialInput;
|
|
590
|
+
|
|
591
|
+
for (;;) {
|
|
592
|
+
const response = await openai.responses.create({
|
|
593
|
+
model: "gpt-6-astra",
|
|
594
|
+
reasoning: { effort },
|
|
595
|
+
instructions,
|
|
596
|
+
tools,
|
|
597
|
+
input,
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
// Preserve every returned item, including reasoning/tool items.
|
|
601
|
+
input = input.concat(response.output);
|
|
602
|
+
|
|
603
|
+
const calls = response.output.filter(
|
|
604
|
+
(item) => item.type === "function_call"
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
if (calls.length === 0) {
|
|
608
|
+
return {
|
|
609
|
+
responseId: response.id,
|
|
610
|
+
text: response.output_text,
|
|
611
|
+
output: response.output,
|
|
612
|
+
usage: response.usage,
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const outputs = await executeAuthorizedCalls(calls);
|
|
617
|
+
|
|
618
|
+
input = input.concat(
|
|
619
|
+
outputs.map(({ callId, result }) => ({
|
|
620
|
+
type: "function_call_output",
|
|
621
|
+
call_id: callId,
|
|
622
|
+
output: JSON.stringify(result),
|
|
623
|
+
}))
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
The essential invariant is:
|
|
629
|
+
|
|
630
|
+
```text
|
|
631
|
+
function_call.call_id
|
|
632
|
+
↓
|
|
633
|
+
execute tool
|
|
634
|
+
↓
|
|
635
|
+
function_call_output.call_id
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
The original `call_id` must be preserved.
|
|
639
|
+
|
|
640
|
+
Assume a response may contain:
|
|
641
|
+
|
|
642
|
+
```text
|
|
643
|
+
zero calls
|
|
644
|
+
one call
|
|
645
|
+
many calls
|
|
646
|
+
reasoning items
|
|
647
|
+
tool-search items
|
|
648
|
+
assistant messages
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
rather than designing only around the one-function tutorial case.
|
|
652
|
+
|
|
653
|
+
---
|
|
654
|
+
|
|
655
|
+
# 12. Parallel execution
|
|
656
|
+
|
|
657
|
+
Because a response can contain several independent calls, the AgentSam executor should be capable of parallel execution where safe.
|
|
658
|
+
|
|
659
|
+
For example:
|
|
660
|
+
|
|
661
|
+
```text
|
|
662
|
+
read package.json
|
|
663
|
+
read wrangler.toml
|
|
664
|
+
inspect git status
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
can often run concurrently.
|
|
668
|
+
|
|
669
|
+
Actions such as:
|
|
670
|
+
|
|
671
|
+
```text
|
|
672
|
+
modify file
|
|
673
|
+
commit
|
|
674
|
+
merge
|
|
675
|
+
deploy
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
usually have ordering dependencies and should be serialized according to AgentSam's execution graph.
|
|
679
|
+
|
|
680
|
+
`parallel_tool_calls` permits the model to request concurrent work, but application-side scheduling remains authoritative.
|
|
681
|
+
|
|
682
|
+
---
|
|
683
|
+
|
|
684
|
+
# 13. Async tool calling
|
|
685
|
+
|
|
686
|
+
Astra introduces async tool calling.
|
|
687
|
+
|
|
688
|
+
With a function or custom tool configured with:
|
|
689
|
+
|
|
690
|
+
```ts
|
|
691
|
+
async: true
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
Astra can continue reasoning, invoke other tools, or answer independent parts of the task while AgentSam executes longer-running work. The eventual result is still returned against the original `call_id`.
|
|
695
|
+
|
|
696
|
+
Good future AgentSam candidates include:
|
|
697
|
+
|
|
698
|
+
```text
|
|
699
|
+
large repository indexing
|
|
700
|
+
long builds
|
|
701
|
+
remote deployments
|
|
702
|
+
security scans
|
|
703
|
+
browser jobs
|
|
704
|
+
large test suites
|
|
705
|
+
external agent runs
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
Do **not** make every tool async.
|
|
709
|
+
|
|
710
|
+
Phase 1 should get the ordinary deterministic tool loop correct.
|
|
711
|
+
|
|
712
|
+
Phase 2 can opt long-running operations into async execution.
|
|
713
|
+
|
|
714
|
+
---
|
|
715
|
+
|
|
716
|
+
# 14. Conversation state
|
|
717
|
+
|
|
718
|
+
AgentSam should remain the canonical conversation/state owner.
|
|
719
|
+
|
|
720
|
+
OpenAI state may optimize continuation, but it should not become the only durable copy of an AgentSam conversation.
|
|
721
|
+
|
|
722
|
+
Two valid Responses patterns exist:
|
|
723
|
+
|
|
724
|
+
```text
|
|
725
|
+
A. previous_response_id continuation
|
|
726
|
+
|
|
727
|
+
B. explicit replay of relevant Response output/input items
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
For the first AgentSam implementation, persist at minimum:
|
|
731
|
+
|
|
732
|
+
```text
|
|
733
|
+
AgentSam conversation ID
|
|
734
|
+
OpenAI response ID
|
|
735
|
+
model
|
|
736
|
+
reasoning effort
|
|
737
|
+
request metadata
|
|
738
|
+
tool calls
|
|
739
|
+
tool results
|
|
740
|
+
usage
|
|
741
|
+
final status
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
A crucial detail: the Responses `instructions` field applies to the current request. When using `previous_response_id`, previous instructions are not automatically treated as the new request's instruction field.
|
|
745
|
+
|
|
746
|
+
Therefore every AgentSamAstra request should deliberately provide the current compiled `AGENTSAM.md` instruction contract.
|
|
747
|
+
|
|
748
|
+
Do not assume it survived because the previous response ID exists.
|
|
749
|
+
|
|
750
|
+
---
|
|
751
|
+
|
|
752
|
+
# 15. Prompt caching
|
|
753
|
+
|
|
754
|
+
The stable portion of AgentSam's prompt should remain stable.
|
|
755
|
+
|
|
756
|
+
Recommended order:
|
|
757
|
+
|
|
758
|
+
```text
|
|
759
|
+
AGENTSAM.md
|
|
760
|
+
stable provider policy
|
|
761
|
+
stable capability guidance
|
|
762
|
+
|
|
763
|
+
then
|
|
764
|
+
|
|
765
|
+
task-specific context
|
|
766
|
+
retrieval
|
|
767
|
+
files
|
|
768
|
+
current user input
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
OpenAI recommends placing reusable prompt material early so the prompt prefix can benefit from caching.
|
|
772
|
+
|
|
773
|
+
Avoid generating a giant slightly different system prompt every turn.
|
|
774
|
+
|
|
775
|
+
That destroys the point of having a canonical instruction contract and reduces cache reuse.
|
|
776
|
+
|
|
777
|
+
---
|
|
778
|
+
|
|
779
|
+
# 16. Code Interpreter
|
|
780
|
+
|
|
781
|
+
Astra supports OpenAI's Code Interpreter.
|
|
782
|
+
|
|
783
|
+
It provides a sandboxed Python environment and can process files, perform data analysis, generate files, and iteratively run Python.
|
|
784
|
+
|
|
785
|
+
Example configuration:
|
|
786
|
+
|
|
787
|
+
```ts
|
|
788
|
+
{
|
|
789
|
+
type: "code_interpreter",
|
|
790
|
+
container: {
|
|
791
|
+
type: "auto",
|
|
792
|
+
memory_limit: "1g"
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
Available documented memory tiers include:
|
|
798
|
+
|
|
799
|
+
```text
|
|
800
|
+
1 GB
|
|
801
|
+
4 GB
|
|
802
|
+
16 GB
|
|
803
|
+
64 GB
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
OpenAI containers are **ephemeral**. A container expires after 20 minutes of inactivity and its associated data cannot then be recovered.
|
|
807
|
+
Therefore:
|
|
808
|
+
|
|
809
|
+
```text
|
|
810
|
+
OpenAI container = temporary compute
|
|
811
|
+
AgentSam storage = durable authority
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
Never treat a Code Interpreter container as the canonical AgentSam filesystem.
|
|
815
|
+
|
|
816
|
+
Any artifact worth retaining must be imported into AgentSam-controlled storage before the ephemeral container disappears.
|
|
817
|
+
|
|
818
|
+
---
|
|
819
|
+
|
|
820
|
+
# 17. Native AgentSam execution versus hosted OpenAI execution
|
|
821
|
+
|
|
822
|
+
AgentSam should deliberately select the execution backend.
|
|
823
|
+
|
|
824
|
+
```text
|
|
825
|
+
AgentSam terminal/sandbox
|
|
826
|
+
→ repository operations
|
|
827
|
+
→ builds
|
|
828
|
+
→ package managers
|
|
829
|
+
→ application runtime
|
|
830
|
+
→ deployment tooling
|
|
831
|
+
|
|
832
|
+
OpenAI Code Interpreter
|
|
833
|
+
→ Python analysis
|
|
834
|
+
→ data transformation
|
|
835
|
+
→ temporary file processing
|
|
836
|
+
→ calculation
|
|
837
|
+
→ model-directed analytical work
|
|
838
|
+
```
|
|
839
|
+
|
|
840
|
+
Do not silently move repository authority into OpenAI's ephemeral Python container merely because Astra supports it.
|
|
841
|
+
|
|
842
|
+
Likewise, hosted shell, computer use, Apply Patch, web search, and other built-in tools should be explicitly represented as execution capabilities, not invisibly mixed with AgentSam-native tools.
|
|
843
|
+
|
|
844
|
+
---
|
|
845
|
+
|
|
846
|
+
# 18. Retrieval and files
|
|
847
|
+
|
|
848
|
+
Retrieval should be task-driven.
|
|
849
|
+
|
|
850
|
+
Do not preload a full repository, project, workspace, or account corpus into every Astra request.
|
|
851
|
+
|
|
852
|
+
Instead:
|
|
853
|
+
|
|
854
|
+
```text
|
|
855
|
+
user task
|
|
856
|
+
↓
|
|
857
|
+
determine needed context
|
|
858
|
+
↓
|
|
859
|
+
search/retrieve
|
|
860
|
+
↓
|
|
861
|
+
load relevant slices
|
|
862
|
+
↓
|
|
863
|
+
perform work
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
OpenAI describes adding relevant external context as retrieval-augmented generation and supports both application-managed retrieval and built-in file search.
|
|
867
|
+
|
|
868
|
+
For AgentSam, that means its own account/repository retrieval layer can remain the canonical code-intelligence system.
|
|
869
|
+
|
|
870
|
+
OpenAI file search is another capability, not a mandatory replacement.
|
|
871
|
+
|
|
872
|
+
---
|
|
873
|
+
|
|
874
|
+
# 19. Streaming
|
|
875
|
+
|
|
876
|
+
The production AgentSamAstra adapter should stream Responses events rather than waiting for a fully buffered result.
|
|
877
|
+
|
|
878
|
+
The UI should be able to distinguish:
|
|
879
|
+
|
|
880
|
+
```text
|
|
881
|
+
assistant text delta
|
|
882
|
+
reasoning/status event
|
|
883
|
+
tool search
|
|
884
|
+
tool call
|
|
885
|
+
tool execution
|
|
886
|
+
tool result
|
|
887
|
+
final assistant text
|
|
888
|
+
usage/final status
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
Do not collapse every event into an undifferentiated text stream.
|
|
892
|
+
|
|
893
|
+
This becomes especially important once async tools and mid-turn steering are introduced.
|
|
894
|
+
|
|
895
|
+
---
|
|
896
|
+
|
|
897
|
+
# 20. Mid-turn steering
|
|
898
|
+
|
|
899
|
+
Astra supports adding instructions while work is in progress over a WebSocket-based Responses flow.
|
|
900
|
+
|
|
901
|
+
That creates a future AgentSam capability:
|
|
902
|
+
|
|
903
|
+
```text
|
|
904
|
+
Agent is working
|
|
905
|
+
↓
|
|
906
|
+
user: "don't touch that migration"
|
|
907
|
+
↓
|
|
908
|
+
steering event
|
|
909
|
+
↓
|
|
910
|
+
same active task continues with updated instruction
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
OpenAI says the completed work already present in the active Responses session can be preserved while the new instruction affects the continuation.
|
|
914
|
+
|
|
915
|
+
Treat this as Phase 3.
|
|
916
|
+
|
|
917
|
+
Do not block the initial Astra integration on it.
|
|
918
|
+
|
|
919
|
+
---
|
|
920
|
+
|
|
921
|
+
# 21. Cost contract
|
|
922
|
+
|
|
923
|
+
As of September 12, 2026, current OpenAI documentation lists GPT-6 Astra Standard short-context pricing per million tokens as:
|
|
924
|
+
|
|
925
|
+
```text
|
|
926
|
+
input $10.00
|
|
927
|
+
cached input $1.00
|
|
928
|
+
cache write $12.50
|
|
929
|
+
output $50.00
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
Long-context pricing is higher once the documented threshold is crossed. Current pricing shows:
|
|
933
|
+
|
|
934
|
+
```text
|
|
935
|
+
long input $20.00
|
|
936
|
+
long cached input $2.00
|
|
937
|
+
long cache write $25.00
|
|
938
|
+
long output $75.00
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
The Astra model documentation currently states that Batch and Flex are priced at 50% of Standard rates and Fast mode at 2× applicable rates.
|
|
942
|
+
|
|
943
|
+
Built-in tools can add separate cost. The supplied pricing documentation currently lists charges for capabilities including web search, containers, file-search storage, and tool calls.
|
|
944
|
+
|
|
945
|
+
Therefore every OpenAI run should capture:
|
|
946
|
+
|
|
947
|
+
```text
|
|
948
|
+
input tokens
|
|
949
|
+
cached input tokens
|
|
950
|
+
cache-write tokens
|
|
951
|
+
output tokens
|
|
952
|
+
reasoning tokens where exposed
|
|
953
|
+
tool-call counts
|
|
954
|
+
container usage
|
|
955
|
+
selected service tier
|
|
956
|
+
estimated/actual cost
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
Cost should become normal AgentSam run telemetry rather than a provider-dashboard-only concern.
|
|
960
|
+
|
|
961
|
+
---
|
|
962
|
+
|
|
963
|
+
# 22. Model routing
|
|
964
|
+
|
|
965
|
+
`gpt-6-astra` should be a real model catalog entry, not a hard-coded exception.
|
|
966
|
+
|
|
967
|
+
Conceptually:
|
|
968
|
+
|
|
969
|
+
```json
|
|
970
|
+
{
|
|
971
|
+
"model_key": "openai:gpt-6-astra",
|
|
972
|
+
"provider": "openai",
|
|
973
|
+
"provider_model": "gpt-6-astra",
|
|
974
|
+
"api_family": "responses",
|
|
975
|
+
"reasoning": true,
|
|
976
|
+
"tool_calling": true,
|
|
977
|
+
"tool_search": true,
|
|
978
|
+
"async_tools": true,
|
|
979
|
+
"computer_use": true,
|
|
980
|
+
"code_interpreter": true,
|
|
981
|
+
"context_window": 1050000,
|
|
982
|
+
"max_output_tokens": 128000
|
|
983
|
+
}
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
Provider adapters should receive a resolved model configuration.
|
|
987
|
+
|
|
988
|
+
They should not perform a second competing model-selection process.
|
|
989
|
+
|
|
990
|
+
---
|
|
991
|
+
|
|
992
|
+
# 23. Recommended implementation boundary
|
|
993
|
+
|
|
994
|
+
Use a small provider package.
|
|
995
|
+
|
|
996
|
+
```text
|
|
997
|
+
backend/
|
|
998
|
+
└── agentsam/
|
|
999
|
+
└── providers/
|
|
1000
|
+
└── openai/
|
|
1001
|
+
├── client.ts
|
|
1002
|
+
├── responses.ts
|
|
1003
|
+
├── stream.ts
|
|
1004
|
+
├── state.ts
|
|
1005
|
+
├── tools.ts
|
|
1006
|
+
├── tool-search.ts
|
|
1007
|
+
├── usage.ts
|
|
1008
|
+
├── errors.ts
|
|
1009
|
+
└── types.ts
|
|
1010
|
+
|
|
1011
|
+
agentsam/
|
|
1012
|
+
├── AGENTSAM.md
|
|
1013
|
+
└── prompts/
|
|
1014
|
+
├── compile.ts
|
|
1015
|
+
└── types.ts
|
|
1016
|
+
|
|
1017
|
+
backend/
|
|
1018
|
+
└── agentsam/
|
|
1019
|
+
└── tools/
|
|
1020
|
+
├── registry.ts
|
|
1021
|
+
├── namespaces.ts
|
|
1022
|
+
├── execute.ts
|
|
1023
|
+
├── permissions.ts
|
|
1024
|
+
└── result.ts
|
|
1025
|
+
```
|
|
1026
|
+
|
|
1027
|
+
Exact repository placement can follow the existing monorepo conventions, but responsibilities should remain separate:
|
|
1028
|
+
|
|
1029
|
+
```text
|
|
1030
|
+
OpenAI adapter
|
|
1031
|
+
knows OpenAI
|
|
1032
|
+
|
|
1033
|
+
tool registry
|
|
1034
|
+
knows AgentSam capabilities
|
|
1035
|
+
|
|
1036
|
+
executor
|
|
1037
|
+
knows how AgentSam executes tools
|
|
1038
|
+
|
|
1039
|
+
authorization
|
|
1040
|
+
knows whether execution is allowed
|
|
1041
|
+
|
|
1042
|
+
AGENTSAM.md compiler
|
|
1043
|
+
knows behavioral instructions
|
|
1044
|
+
|
|
1045
|
+
router
|
|
1046
|
+
chooses the model
|
|
1047
|
+
|
|
1048
|
+
chat/work UI
|
|
1049
|
+
consumes normalized runtime events
|
|
1050
|
+
```
|
|
1051
|
+
|
|
1052
|
+
---
|
|
1053
|
+
|
|
1054
|
+
# 24. Normalized AgentSam response protocol
|
|
1055
|
+
|
|
1056
|
+
Do not expose raw OpenAI response objects throughout the application.
|
|
1057
|
+
|
|
1058
|
+
Normalize them at the provider boundary.
|
|
1059
|
+
|
|
1060
|
+
Example:
|
|
1061
|
+
|
|
1062
|
+
```ts
|
|
1063
|
+
type AgentSamProviderEvent =
|
|
1064
|
+
| { type: "text_delta"; text: string }
|
|
1065
|
+
| { type: "tool_search"; query?: string }
|
|
1066
|
+
| {
|
|
1067
|
+
type: "tool_call";
|
|
1068
|
+
callId: string;
|
|
1069
|
+
name: string;
|
|
1070
|
+
arguments: unknown;
|
|
1071
|
+
}
|
|
1072
|
+
| {
|
|
1073
|
+
type: "tool_result";
|
|
1074
|
+
callId: string;
|
|
1075
|
+
result: unknown;
|
|
1076
|
+
}
|
|
1077
|
+
| { type: "status"; status: string }
|
|
1078
|
+
| {
|
|
1079
|
+
type: "usage";
|
|
1080
|
+
inputTokens: number;
|
|
1081
|
+
outputTokens: number;
|
|
1082
|
+
cachedInputTokens?: number;
|
|
1083
|
+
reasoningTokens?: number;
|
|
1084
|
+
}
|
|
1085
|
+
| {
|
|
1086
|
+
type: "completed";
|
|
1087
|
+
responseId: string;
|
|
1088
|
+
text: string;
|
|
1089
|
+
};
|
|
1090
|
+
```
|
|
1091
|
+
|
|
1092
|
+
That keeps the rest of AgentSam provider-neutral while allowing the OpenAI implementation to use the full Responses protocol.
|
|
1093
|
+
|
|
1094
|
+
---
|
|
1095
|
+
|
|
1096
|
+
# 25. Error handling
|
|
1097
|
+
|
|
1098
|
+
The provider adapter should explicitly classify:
|
|
1099
|
+
|
|
1100
|
+
```text
|
|
1101
|
+
authentication failure
|
|
1102
|
+
rate limit
|
|
1103
|
+
spend/quota failure
|
|
1104
|
+
invalid schema
|
|
1105
|
+
invalid tool result
|
|
1106
|
+
unknown call_id
|
|
1107
|
+
context overflow
|
|
1108
|
+
model unavailable
|
|
1109
|
+
container expired
|
|
1110
|
+
tool timeout
|
|
1111
|
+
stream interruption
|
|
1112
|
+
provider 5xx
|
|
1113
|
+
user cancellation
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1116
|
+
Do not turn all provider failures into:
|
|
1117
|
+
|
|
1118
|
+
```text
|
|
1119
|
+
Something went wrong
|
|
1120
|
+
```
|
|
1121
|
+
|
|
1122
|
+
Likewise, do not retry blindly.
|
|
1123
|
+
|
|
1124
|
+
A schema rejection and a transient network failure are fundamentally different problems.
|
|
1125
|
+
|
|
1126
|
+
---
|
|
1127
|
+
|
|
1128
|
+
# 26. Telemetry
|
|
1129
|
+
|
|
1130
|
+
Each Astra turn should produce one coherent turn record.
|
|
1131
|
+
|
|
1132
|
+
Minimum useful fields:
|
|
1133
|
+
|
|
1134
|
+
```text
|
|
1135
|
+
run_id
|
|
1136
|
+
conversation_id
|
|
1137
|
+
account_id
|
|
1138
|
+
model_key
|
|
1139
|
+
provider
|
|
1140
|
+
provider_response_id
|
|
1141
|
+
|
|
1142
|
+
mode
|
|
1143
|
+
reasoning_effort
|
|
1144
|
+
service_tier
|
|
1145
|
+
|
|
1146
|
+
started_at
|
|
1147
|
+
first_event_at
|
|
1148
|
+
completed_at
|
|
1149
|
+
|
|
1150
|
+
input_tokens
|
|
1151
|
+
cached_input_tokens
|
|
1152
|
+
cache_write_tokens
|
|
1153
|
+
output_tokens
|
|
1154
|
+
reasoning_tokens
|
|
1155
|
+
|
|
1156
|
+
tool_search_count
|
|
1157
|
+
tool_call_count
|
|
1158
|
+
tool_names
|
|
1159
|
+
tool_failures
|
|
1160
|
+
|
|
1161
|
+
status
|
|
1162
|
+
error_code
|
|
1163
|
+
|
|
1164
|
+
estimated_cost
|
|
1165
|
+
```
|
|
1166
|
+
|
|
1167
|
+
This makes latency, tool behavior, routing quality, and cost observable without dumping every internal event into production logs.
|
|
1168
|
+
|
|
1169
|
+
---
|
|
1170
|
+
|
|
1171
|
+
# 27. Security boundary
|
|
1172
|
+
|
|
1173
|
+
Function calling does not turn model output into trusted application input.
|
|
1174
|
+
|
|
1175
|
+
Treat every function call like structured untrusted input:
|
|
1176
|
+
|
|
1177
|
+
```text
|
|
1178
|
+
model proposes
|
|
1179
|
+
↓
|
|
1180
|
+
JSON schema validates
|
|
1181
|
+
↓
|
|
1182
|
+
AgentSam resolves authority
|
|
1183
|
+
↓
|
|
1184
|
+
permission/risk policy checks
|
|
1185
|
+
↓
|
|
1186
|
+
application executes
|
|
1187
|
+
↓
|
|
1188
|
+
result returned to model
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
Never use a model-created account, user, repository, filesystem root, credential, or connection identifier as proof of authority.
|
|
1192
|
+
|
|
1193
|
+
The frontend is also not an authority boundary.
|
|
1194
|
+
|
|
1195
|
+
Permissions that matter must be enforced server-side.
|
|
1196
|
+
|
|
1197
|
+
---
|
|
1198
|
+
|
|
1199
|
+
# 28. Phase 1 — make Astra real
|
|
1200
|
+
|
|
1201
|
+
The first implementation milestone is intentionally narrow.
|
|
1202
|
+
|
|
1203
|
+
Build:
|
|
1204
|
+
|
|
1205
|
+
1. `openai` SDK/provider client.
|
|
1206
|
+
2. `gpt-6-astra` catalog entry.
|
|
1207
|
+
3. Responses API request path.
|
|
1208
|
+
4. `AGENTSAM.md` loader/compiler.
|
|
1209
|
+
5. `reasoning.effort`.
|
|
1210
|
+
6. streaming response support.
|
|
1211
|
+
7. strict function tools.
|
|
1212
|
+
8. complete multi-call tool loop.
|
|
1213
|
+
9. `call_id` preservation.
|
|
1214
|
+
10. usage/cost telemetry.
|
|
1215
|
+
11. cancellation.
|
|
1216
|
+
12. a small eager tool surface.
|
|
1217
|
+
13. `tool_search`.
|
|
1218
|
+
14. deferred AgentSam tool namespaces.
|
|
1219
|
+
|
|
1220
|
+
Proof should include:
|
|
1221
|
+
|
|
1222
|
+
```text
|
|
1223
|
+
plain text turn
|
|
1224
|
+
reasoning turn
|
|
1225
|
+
one function call
|
|
1226
|
+
multiple function calls
|
|
1227
|
+
deferred tool discovered through tool_search
|
|
1228
|
+
tool failure returned to Astra
|
|
1229
|
+
follow-up after tool output
|
|
1230
|
+
stream cancellation
|
|
1231
|
+
usage captured
|
|
1232
|
+
```
|
|
1233
|
+
|
|
1234
|
+
---
|
|
1235
|
+
|
|
1236
|
+
# 29. Phase 2 — tool and state optimization
|
|
1237
|
+
|
|
1238
|
+
After the base runtime is stable:
|
|
1239
|
+
|
|
1240
|
+
```text
|
|
1241
|
+
async tool calling
|
|
1242
|
+
configuration_update reasoning changes
|
|
1243
|
+
prompt-cache diagnostics
|
|
1244
|
+
larger namespace catalog
|
|
1245
|
+
MCP deferred discovery
|
|
1246
|
+
parallel executor scheduling
|
|
1247
|
+
state continuation optimization
|
|
1248
|
+
compaction
|
|
1249
|
+
provider failover
|
|
1250
|
+
cost-aware model routing
|
|
1251
|
+
```
|
|
1252
|
+
|
|
1253
|
+
The key measurement is no longer merely "does Astra work?"
|
|
1254
|
+
|
|
1255
|
+
Measure:
|
|
1256
|
+
|
|
1257
|
+
```text
|
|
1258
|
+
time to first event
|
|
1259
|
+
time to first useful text
|
|
1260
|
+
tool-selection accuracy
|
|
1261
|
+
tool-search accuracy
|
|
1262
|
+
unnecessary tool calls
|
|
1263
|
+
schema failures
|
|
1264
|
+
tokens per completed task
|
|
1265
|
+
cost per completed task
|
|
1266
|
+
task completion rate
|
|
1267
|
+
```
|
|
1268
|
+
|
|
1269
|
+
---
|
|
1270
|
+
|
|
1271
|
+
# 30. Phase 3 — AgentSamAstra as a full work agent
|
|
1272
|
+
|
|
1273
|
+
Then enable capabilities that depend on the stable event/runtime contract:
|
|
1274
|
+
|
|
1275
|
+
```text
|
|
1276
|
+
mid-turn steering
|
|
1277
|
+
long-running async jobs
|
|
1278
|
+
subagent orchestration
|
|
1279
|
+
computer use
|
|
1280
|
+
hosted shell where appropriate
|
|
1281
|
+
Apply Patch
|
|
1282
|
+
browser workflows
|
|
1283
|
+
cross-tool concurrency
|
|
1284
|
+
checkpoint/resume
|
|
1285
|
+
richer artifact handling
|
|
1286
|
+
```
|
|
1287
|
+
|
|
1288
|
+
At this stage `AgentSamAstra` becomes an agent runtime rather than merely an OpenAI model option.
|
|
1289
|
+
|
|
1290
|
+
---
|
|
1291
|
+
|
|
1292
|
+
# 31. Acceptance criteria
|
|
1293
|
+
|
|
1294
|
+
The integration is complete only when this works end to end:
|
|
1295
|
+
|
|
1296
|
+
```text
|
|
1297
|
+
User:
|
|
1298
|
+
"Audit this repo, find the terminal connection bug,
|
|
1299
|
+
repair it, run the appropriate tests, and tell me what changed."
|
|
1300
|
+
|
|
1301
|
+
↓
|
|
1302
|
+
|
|
1303
|
+
AgentSam authenticates account
|
|
1304
|
+
↓
|
|
1305
|
+
loads stable AGENTSAM.md
|
|
1306
|
+
↓
|
|
1307
|
+
selects gpt-6-astra
|
|
1308
|
+
↓
|
|
1309
|
+
starts Responses stream
|
|
1310
|
+
↓
|
|
1311
|
+
Astra sees small eager tool set
|
|
1312
|
+
↓
|
|
1313
|
+
uses tool_search for repo/terminal tools
|
|
1314
|
+
↓
|
|
1315
|
+
AgentSam validates tool args
|
|
1316
|
+
↓
|
|
1317
|
+
executes authorized repository operations
|
|
1318
|
+
↓
|
|
1319
|
+
returns outputs with correct call_ids
|
|
1320
|
+
↓
|
|
1321
|
+
Astra continues reasoning
|
|
1322
|
+
↓
|
|
1323
|
+
edits code through authorized execution lane
|
|
1324
|
+
↓
|
|
1325
|
+
runs proportionate verification
|
|
1326
|
+
↓
|
|
1327
|
+
receives results
|
|
1328
|
+
↓
|
|
1329
|
+
produces final answer
|
|
1330
|
+
↓
|
|
1331
|
+
AgentSam stores response ID, usage,
|
|
1332
|
+
tool telemetry, timing, and cost
|
|
1333
|
+
```
|
|
1334
|
+
|
|
1335
|
+
with no hidden workspace bootstrap, no giant tool dump, no fake execution, no provider-specific state leaking throughout the UI, and no requirement for the model to manufacture authority information.
|
|
1336
|
+
|
|
1337
|
+
That is the `AgentSamAstra` baseline.
|
|
1338
|
+
|
|
1339
|
+
---
|
|
1340
|
+
|
|
1341
|
+
# 32. The implementation rule to keep
|
|
1342
|
+
|
|
1343
|
+
The main abstraction should be:
|
|
1344
|
+
|
|
1345
|
+
```text
|
|
1346
|
+
AgentSam decides what exists and what is authorized.
|
|
1347
|
+
|
|
1348
|
+
AGENTSAM.md defines how the agent should behave.
|
|
1349
|
+
|
|
1350
|
+
The Responses API carries the reasoning/tool conversation.
|
|
1351
|
+
|
|
1352
|
+
Astra decides what capability it needs.
|
|
1353
|
+
|
|
1354
|
+
tool_search discovers the relevant capability.
|
|
1355
|
+
|
|
1356
|
+
AgentSam executes it.
|
|
1357
|
+
|
|
1358
|
+
The tool result goes back through the same response loop.
|
|
1359
|
+
|
|
1360
|
+
AgentSam owns the durable state and evidence.
|
|
1361
|
+
```
|
|
1362
|
+
|
|
1363
|
+
Everything else should build on that contract.
|