teapot-coding-agent 0.37.158 → 0.37.159
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/dist/agent/agent.js +16 -9
- package/dist/agent/context-claim.js +23 -6
- package/dist/agent/meta-tools.js +10 -2
- package/dist/agent/tools.js +1 -1
- package/package.json +1 -1
- package/public/assets/{index-BB5ne3kd.js → index-DojS-kKE.js} +5 -5
- package/public/assets/index-DojS-kKE.js.map +1 -0
- package/public/index.html +1 -1
- package/public/assets/index-BB5ne3kd.js.map +0 -1
package/dist/agent/agent.js
CHANGED
|
@@ -82,7 +82,7 @@ const SUMMARY_CLOSE = "\n</conversation_checkpoint>";
|
|
|
82
82
|
const AUDIT_READ_ONLY_TOOLS = new Set(["read_file", "list_dir", "grep", "bash"]);
|
|
83
83
|
/** tool calls that decide/announce rather than do — they must not reset the "was that stop justified?" bounds */
|
|
84
84
|
const NON_WORK_TOOLS = new Set([
|
|
85
|
-
"finish", "report_progress", "ask_user", "set_goal", "get_goal", "get_todo", "set_todo",
|
|
85
|
+
"finish", "report_progress", "ask_operator", "ask_user", "set_goal", "get_goal", "get_todo", "set_todo",
|
|
86
86
|
]);
|
|
87
87
|
const SYSTEM_TEMPLATE = `You are a coding agent working autonomously inside a workspace.
|
|
88
88
|
|
|
@@ -96,9 +96,9 @@ Most session state is not injected into prompts — fetch it with tools instead:
|
|
|
96
96
|
compaction notice, or whenever you lose the thread.
|
|
97
97
|
- set_goal(text) → change the objective itself (not routine updates).
|
|
98
98
|
- finish(goalComplete=true, summary) → goal fully achieved.
|
|
99
|
-
-
|
|
99
|
+
- ask_operator(question, options?) → park the loop and wait for the operator's
|
|
100
100
|
decision (plan confirmation, ambiguity). One concrete question at a time.
|
|
101
|
-
Which one ends the turn: finish() closes the round,
|
|
101
|
+
Which one ends the turn: finish() closes the round, ask_operator() parks it until
|
|
102
102
|
the operator answers, and report_progress() does NOT end it — that output goes
|
|
103
103
|
to the operator's progress panel and you carry on working.
|
|
104
104
|
- read_memory(query?) / add_memory(text) / forget_memory(query) / set_memory(content)
|
|
@@ -169,7 +169,7 @@ Most session state is not injected into prompts — fetch it with tools instead:
|
|
|
169
169
|
- Be frugal: prefer small precise edits, avoid runaway loops.
|
|
170
170
|
- **Two failures on the same cause is the signal to change approach, not to try
|
|
171
171
|
a third time.** Reread the error, list what you have already ruled out, and
|
|
172
|
-
then either fix the actual cause or
|
|
172
|
+
then either fix the actual cause or ask_operator with what you know: two concrete
|
|
173
173
|
options and the evidence for each. Grinding a third variation of a failing idea
|
|
174
174
|
is the costliest loop there is, because it looks like progress.
|
|
175
175
|
- When the operator asks you to remember something, WRITE it with add_memory.
|
|
@@ -290,7 +290,7 @@ export class Agent {
|
|
|
290
290
|
`would land you here again in a few turns. Change the perspective instead:\n` +
|
|
291
291
|
`1. Write down what you have LEARNED (add_memory) and what is LEFT (set_todo), so nothing depends on ` +
|
|
292
292
|
`holding this conversation in your head.\n` +
|
|
293
|
-
`2. Name the exact question you cannot answer ("I cannot tell whether X, because Y") and call
|
|
293
|
+
`2. Name the exact question you cannot answer ("I cannot tell whether X, because Y") and call ask_operator with ` +
|
|
294
294
|
`it — or list what you have already ruled out and pick a different mechanism that produces the same evidence.\n` +
|
|
295
295
|
`3. Choose the SMALLEST next step that produces evidence — one experiment, not a longer version of the same ` +
|
|
296
296
|
`attempt.\n` +
|
|
@@ -321,7 +321,7 @@ export class Agent {
|
|
|
321
321
|
* time and task size. Telling it the real percentage each turn costs nothing (this line is already
|
|
322
322
|
* per-message) and removes the inference.
|
|
323
323
|
*/
|
|
324
|
-
return `${clock} · ${usageLine(this.contextSizeForBudgeting(), this.opts.contextTokenBudget)}`;
|
|
324
|
+
return `${clock} · ${usageLine(this.contextSizeForBudgeting(), this.opts.contextTokenBudget, this.opts.contextWindowTokens)}`;
|
|
325
325
|
}
|
|
326
326
|
activityChars = 0;
|
|
327
327
|
turnsSinceProgress = 0;
|
|
@@ -1890,7 +1890,7 @@ export class Agent {
|
|
|
1890
1890
|
}, null, 1));
|
|
1891
1891
|
return "next";
|
|
1892
1892
|
},
|
|
1893
|
-
|
|
1893
|
+
ask_operator: async (call, m) => {
|
|
1894
1894
|
const a = safeParse(call.function.arguments);
|
|
1895
1895
|
const question = String(a.question ?? "").slice(0, 2000);
|
|
1896
1896
|
const options = Array.isArray(a.options)
|
|
@@ -2353,7 +2353,14 @@ export class Agent {
|
|
|
2353
2353
|
await this.answerUnansweredToolCalls(m);
|
|
2354
2354
|
return finished;
|
|
2355
2355
|
}
|
|
2356
|
-
|
|
2356
|
+
/**
|
|
2357
|
+
* `ask_user` is the pre-rename name of `ask_operator` and stays dispatchable.
|
|
2358
|
+
*
|
|
2359
|
+
* One normalization point: a prompt written before the rename, a session resumed mid-call, or an operator's own
|
|
2360
|
+
* note that still says `ask_user` all keep working. The spec advertises only `ask_operator`.
|
|
2361
|
+
*/
|
|
2362
|
+
const toolName = call.function.name === "ask_user" ? "ask_operator" : call.function.name;
|
|
2363
|
+
const meta = this.metaHandlers[toolName];
|
|
2357
2364
|
if (meta) {
|
|
2358
2365
|
if ((await meta(call, m)) === "end") {
|
|
2359
2366
|
finished = true;
|
|
@@ -3173,7 +3180,7 @@ export class Agent {
|
|
|
3173
3180
|
];
|
|
3174
3181
|
}
|
|
3175
3182
|
else {
|
|
3176
|
-
noticeLine = usageLine(this.estimateTokens(this.messages.slice(cut)), this.opts.contextTokenBudget);
|
|
3183
|
+
noticeLine = usageLine(this.estimateTokens(this.messages.slice(cut)), this.opts.contextTokenBudget, this.opts.contextWindowTokens);
|
|
3177
3184
|
/**
|
|
3178
3185
|
* The usage line is computed ONCE, from the kept tail, and then WRITTEN INTO the compaction event.
|
|
3179
3186
|
*
|
|
@@ -87,13 +87,30 @@ export function claimsContextLimit(text) {
|
|
|
87
87
|
* that comment is just "解釈が逆". A number with no direction is a coin flip, so the direction is now a word, and the
|
|
88
88
|
* remaining room is spelled out in the unit the model actually spends.
|
|
89
89
|
*/
|
|
90
|
-
export function usageLine(used, budget) {
|
|
90
|
+
export function usageLine(used, budget, window) {
|
|
91
91
|
const fmt = (n) => (n >= 1_000 ? `${Math.round(n / 1_000)}k` : String(Math.max(0, Math.round(n))));
|
|
92
|
-
|
|
92
|
+
/**
|
|
93
|
+
* The percentage is of the WINDOW, and the compaction threshold is stated separately.
|
|
94
|
+
*
|
|
95
|
+
* It used to be `used / budget`, where `budget` is the compaction threshold — so a 900k window that compacts at 750k
|
|
96
|
+
* read as "82% used" at 615k and the denominator was a number the model could not see anywhere else. Reported as
|
|
97
|
+
* "生のサイズじゃなくてcompactボーダーまでにしたのはなぜ? 消費/フルサイズ とcompactまでの残り値にすべきでは?".
|
|
98
|
+
*
|
|
99
|
+
* context 68% used (615k/900k tokens, 135k until compaction)
|
|
100
|
+
*
|
|
101
|
+
* When the window is unknown the budget is the only denominator available, and the line says so by omitting the
|
|
102
|
+
* window entirely rather than pretending they are the same thing.
|
|
103
|
+
*/
|
|
104
|
+
const full = Number.isFinite(window) && (window ?? 0) > 0 ? window : 0;
|
|
105
|
+
const denom = full || (Number.isFinite(budget) && budget > 0 ? budget : 0);
|
|
106
|
+
if (!denom)
|
|
93
107
|
return `context ${fmt(used)} tokens used`;
|
|
94
|
-
const pct = Math.max(0, Math.min(100, Math.round((used /
|
|
95
|
-
const
|
|
96
|
-
|
|
108
|
+
const pct = Math.max(0, Math.min(100, Math.round((used / denom) * 100)));
|
|
109
|
+
const until = Number.isFinite(budget) && budget > 0 ? Math.max(0, budget - used) : null;
|
|
110
|
+
const size = full ? `${fmt(used)}/${fmt(full)} tokens` : `${fmt(used)}/${fmt(budget)} tokens (compaction threshold; full window unknown)`;
|
|
111
|
+
return until === null
|
|
112
|
+
? `context ${pct}% used (${size})`
|
|
113
|
+
: `context ${pct}% used (${size}, ${fmt(until)} until compaction)`;
|
|
97
114
|
}
|
|
98
115
|
/**
|
|
99
116
|
* …and the OTHER thing that gets reported as "context is exhausted": the model has run out of its own ideas.
|
|
@@ -101,7 +118,7 @@ export function usageLine(used, budget) {
|
|
|
101
118
|
* "コンテキストが尽きたっていうのがコンテキストウィンドウが尽きたと勘違いしてるパターンと、自力の推論の限界に達した
|
|
102
119
|
* 場合がありそう" — two different problems with different answers. The window case is false and gets corrected with
|
|
103
120
|
* numbers; being STUCK is real, and telling the model to continue would just spin. What a stuck agent needs is to
|
|
104
|
-
* name the question it cannot answer and hand it over (
|
|
121
|
+
* name the question it cannot answer and hand it over (ask_operator) or change angle — not another turn of the same.
|
|
105
122
|
*/
|
|
106
123
|
const OWN_LIMIT_PATTERNS = [
|
|
107
124
|
/(?:reasoning|analysis|own) (?:limit|limits|capacity)s?\b/i,
|
package/dist/agent/meta-tools.js
CHANGED
|
@@ -62,11 +62,19 @@ export const META_TOOLS = [
|
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
|
-
|
|
65
|
+
/**
|
|
66
|
+
* `ask_operator`, not `ask_user`.
|
|
67
|
+
*
|
|
68
|
+
* "モデルがreasoningでoperatorってよく使うから多分そっちのほうがいい" — and the whole system prompt already says
|
|
69
|
+
* "operator" everywhere, so the tool name disagreed with the vocabulary the model is reading. The old name stays
|
|
70
|
+
* DISPATCHABLE (see `TOOL_ALIASES`) so a prompt written before the rename, or a session resumed mid-call, still
|
|
71
|
+
* works; it is simply no longer advertised.
|
|
72
|
+
*/
|
|
73
|
+
name: "ask_operator",
|
|
66
74
|
spec: {
|
|
67
75
|
type: "function",
|
|
68
76
|
function: {
|
|
69
|
-
name: "
|
|
77
|
+
name: "ask_operator",
|
|
70
78
|
description: "Pause and ask the operator a question — plan confirmation, ambiguous requirements, " +
|
|
71
79
|
"a decision only they can make. The loop parks until they reply; their message arrives " +
|
|
72
80
|
"as your next user turn. Use sparingly: do your homework first, then ask once, concretely.",
|
package/dist/agent/tools.js
CHANGED
|
@@ -1778,7 +1778,7 @@ export const TOOLS = [
|
|
|
1778
1778
|
{
|
|
1779
1779
|
name: "message_agent",
|
|
1780
1780
|
description: "Send a message to another agent. Use it to steer a sub-agent mid-flight, to answer its " +
|
|
1781
|
-
"
|
|
1781
|
+
"ask_operator question, or to message your OWN PARENT (pass its id) — a sub-agent may ask its " +
|
|
1782
1782
|
"parent a question or hand back a partial result, which is how you report progress without " +
|
|
1783
1783
|
"ending your turn. You may NOT message a sibling or an unrelated agent.",
|
|
1784
1784
|
parameters: {
|