Commit Graph

37 Commits

Author SHA1 Message Date
NCBM abcb345c0d core/agent: todo review nag as developer role, not fake user
Internal control uses DeveloperChatMessage so retry/history treat it as
non-human. Responses bridge maps developer mid-turn; compact/history label it.
2026-07-18 12:27:15 +08:00
NCBM 596af1ea1b core/agent+tools: session todo/task stack with review nag
Sub-task stack stored on session.todo_stack; model tools todo_*; slash
/todos for human ops; agent loop injects a review user message when open
todos exist and no todo_* tool ran this turn. Stack carries across /compact.
2026-07-18 01:59:13 +08:00
NCBM 65d248064e core/agent: classify empty/truncated/missing stream terminals as errors 2026-07-18 00:56:45 +08:00
NCBM 2761877460 core/cli: YOLO mode on|off|once for soft destructive confirms
Session /yolo and --yes skip classify_danger prompts; once expires after the
next user turn. Hard path/command denylists unchanged.
2026-07-17 14:55:34 +08:00
NCBM 16992be743 core/config+agent: OpenAI provider_tools for hosted Responses tools
Merge opaque tool dicts (web_search, file_search, …) into POST /responses; local ToolRegistry unchanged.
2026-07-15 21:16:05 +08:00
NCBM 5dd102a016 core/agent: route OpenAI provider through Responses API
ResponsesChatClient adapts chat-shaped agent history/tools to POST /responses; compat and DeepSeek unchanged.
2026-07-15 20:59:47 +08:00
NCBM cf7d331634 core/agent: checkpoint tool rounds so /retry does not redo side effects
After each completed assistant+tool batch, persist and keep that prefix on
failure. Rollback only unfinished assistant/stream suffix. pending_retry
and /retry also apply when history ends with tool results (continue model
without re-executing tools).
2026-07-15 15:01:15 +08:00
NCBM 95df11713d core/agent+config: configurable compact prompts
Add agent config compact_system_prompt, compact_user_prefix, and
compact_seed_text; wire through summarize and seed messages. Fix default
user prefix to include {transcript}; use safe seed substitution so braces
in summaries do not break formatting.
2026-07-15 14:45:12 +08:00
NCBM 04d421a4b5 core/agent+cli: reasoning deltas, /stream and /verbose
Decode and stream reasoning_content as ReasoningDeltaEvent; keep it on
assistant messages. CLI shows dim reasoning, toggles stream/verbose, and
prints full tool results when verbose.
2026-07-15 12:11:19 +08:00
NCBM aaf7fe8e7b ci/lint: ruff format pass and fix compact seed test typing
Apply pending ruff format; narrow AssistantChatMessage.content before
membership checks so basedpyright accepts Unset|None unions.
2026-07-15 11:36:01 +08:00
NCBM 6e9e034de4 core/agent: derive pending_retry_text from trailing user message
Drop stored pending field; incomplete turns are just history ending in
UserChatMessage. Compact seeds use an assistant summary so they are not
mistaken for retryable orphans.
2026-07-15 11:27:29 +08:00
NCBM 00a8ed3a9c core/agent+cli: persist user immediately; /retry reuses DB turn
Keep incomplete user messages in memory/DB; roll back only
assistant/tool on failure. /retry and resume of orphan-user sessions
re-run without duplicating the user message.
2026-07-15 11:21:01 +08:00
NCBM b1223c8189 core/agent: calibrate soft-compact with last-request prompt_tokens
After the first model call, scale char-based token estimates by
API/resolved prompt size so budget checks track near-real tokens.
/compact uses the same calibration when available.
2026-07-15 11:11:15 +08:00
NCBM c9e805f38d core/agent+cli: treat last-request prompt_tokens as context size
context_tokens prefers API usage from the last model call; char est.
is only a pre-call fallback. Clarify billed turn/session totals in UI.
2026-07-15 11:07:52 +08:00
NCBM a61b536243 core/agent+cli: separate last-request usage from billed turn totals
Tool-loop rounds re-send history, so summed prompt tokens are billing
not context size. Track last_request_usage and label turn/session as
billed; clarify /status and end-of-turn lines.
2026-07-15 11:04:41 +08:00
NCBM 58041c6c87 core/agent+config: soft context budget in estimated tokens
Replace max_context_chars with max_context_tokens (default 200k est.
tokens via char/4); compact and /status use the token budget.
2026-07-15 10:58:01 +08:00
NCBM 6bdf7ea283 core/agent: always emit UsageEvent with api or estimate
Every model round yields usage; prefer provider usage, else estimate
from request messages and assistant content.
2026-07-15 10:52:48 +08:00
NCBM 0a3127454d core/agent: char-based token estimate fallback for usage
When API usage is missing, estimate prompt/completion tokens at ~4
chars per token and mark source as estimate (or mixed when combined).
2026-07-15 10:52:37 +08:00
NCBM 28b6767b32 core/agent: emit UsageEvent from stream and non-stream rounds
Request stream_options.include_usage; yield usage after each model
completion when the provider reports it.
2026-07-15 10:47:59 +08:00
NCBM 2ae7aa0e05 core/agent: add TokenUsage and API usage parser
Parse OpenAI-compatible usage dicts into prompt/completion/total counts
for session and turn aggregation.
2026-07-15 10:47:51 +08:00
NCBM 5c13e06427 ci/lint: per-file ignores for tests in ruff and basedpyright
Relax ANN/ARG/PLR/C901 and related rules under tests/**; silence noisy
basedpyright reports for test fakes and private helpers.
2026-07-15 10:35:30 +08:00
NCBM 4741341888 core/agent: yield stream text deltas as chunks arrive
Stop buffering the full SSE response before emitting TextDeltaEvent so
CLI/UI can render assistant output token-by-token.
2026-07-15 10:27:49 +08:00
NCBM 001619d9dd core/cli+agent: /compact and resume latest by workspace recency
Soft-compact history, model-summarize without tools, seed a new session;
/resume with no id loads the lately-used session for this workspace.
2026-07-15 10:03:22 +08:00
NCBM a7d9c9879b core/cli+agent: run TTY confirms off the event loop
Max-rounds and destructive-tool prompts use asyncio.to_thread with
cancel paused on the main thread so multi-tool turns no longer look
like user cancel. Hooks may be sync or async.
2026-07-15 09:41:32 +08:00
NCBM 5cfe4d6a24 core/agent: soft context compact and cooperative cancel points
Shrink older tool dumps for model requests without mutating history;
check task cancellation between tool/model steps.
2026-07-14 23:42:50 +08:00
NCBM 35e89c4dcc core/agent: optional confirm hook on ToolRegistry execute
Serialise dangerous-tool prompts under a lock so parallel tool rounds
cannot race the TTY confirm.
2026-07-14 23:30:10 +08:00
NCBM 3363ab928b core/agent+cli: wire system prompt and agent budgets
ChatAgent accepts system_prompt, result budget, and parallel_tools;
CLI loads them from config [agent].
2026-07-14 23:24:23 +08:00
NCBM b1964951ea core/agent: parallel tool calls and tool-result char budget
Truncate large tool outputs and run multiple tool calls in one round
concurrently when enabled.
2026-07-14 23:24:11 +08:00
NCBM bd6d98ceda core/lmproto+agent: stream via chat_completions(stream=True)
Keep library async-def→async-iterator shape; remove raw-lines path;
typed StreamToolCallDelta merge; scripted clients emit real chunks.
2026-07-14 22:40:24 +08:00
NCBM 4548828354 core/lmproto+agent: use normal stream API for chat loop
Accept async-def returning async iterator; stream via
chat_completions(..., stream=True); typed StreamToolCallDelta merge;
update scripted test clients to emit real chunks.
2026-07-14 22:40:15 +08:00
NCBM bdb52bdef5 test/agent: cover merge_stream_tool_calls accumulation 2026-07-14 22:22:22 +08:00
NCBM ed028dc00b core/cli: update display and state for streaming, error, cancel events 2026-07-14 22:11:30 +08:00
NCBM e0916a6352 core/agent+cli: defer DB write until turn success; auto/manual retry
Failed turns roll back memory and keep pending_retry_text; persist only
after success. CLI auto-retries 10s/20s/30s (cancellable) and /retry.
2026-07-14 20:56:08 +08:00
NCBM a634021a80 core/cli: interactive continue prompts for loop and PTY limits
on_limit raises tool-round allowance; PTY session/budget limits can
prompt to raise; MaxRoundsEvent.continued marks extended runs.
2026-07-14 19:53:34 +08:00
NCBM bd6f8f5d9a core/cli: resume sessions, history, editline Tab, higher tool rounds
Default to file SQLite DB and latest session; /history and /rounds;
bind Tab for libedit; max tool rounds default 32.
2026-07-14 19:15:12 +08:00
NCBM 770e239d27 ci/lint: replace dead type:ignore with casts and clean async gen
Drop ignored # type: ignore comments (basedpyright skips them); type
tomlkit tables via cast; empty stream without reportUnreachable.
2026-07-14 18:08:22 +08:00
NCBM 6d536ab913 test/agent: cover tools, loop, and memory-backed ChatAgent 2026-07-14 17:45:47 +08:00