Skip to content

Feat/framework enhance - #49

Merged
wangxingjun778 merged 17 commits into
mainfrom
feat/framework_enhance
Sep 22, 2026
Merged

wangxingjun778 merged 17 commits into
mainfrom
feat/framework_enhance

Conversation

@wangxingjun778

Copy link
Copy Markdown
Member

Feature

  • /btw side-question fiber — lightweight inline question handler that forks a cache-parity isolated fiber, explicitly disabling tools and extended thinking to keep answers fast and cheap.
  • leap doctor — unified diagnostic command with 5 domain checks (config, connectivity, platform, state, tools). Protocol-based and extensible.
  • BM25 tool search — budget-driven progressive disclosure for tool discovery; replaces naive substring matching with ranked retrieval so PCD only surfaces the tools the current turn actually needs.
  • Skill Curator MVP — active / stale / archived lifecycle management for skills, backed by a dedicated skill_curation_store in DuckDB.
  • Scheduler productization — execution-mode unification (local + cloud), agent executor with retry/timeout, structured execution logs, and full CRUD scheduler tools exposed as a tool plugin.
  • SelfAwarenessPlugin — unified agent self-cognition tool giving the LLM structured access to its own identity, capabilities, and runtime state.
  • PCD Cache-Aware mechanism (P0) — prefix-commitment enforcement, cache-boundary propagation, and Anthropic/DeepSeek cache-hit-rate telemetry for system-prompt stability.
  • Subagent dashboard — SDUI template + backend service for monitoring subagent lifecycle, status, and prompt provenance.
  • Live E2E test harness — token-budget-aware live tests against real LLM providers, with configurable cost caps and CI integration.

Refactor

  • Engine god-class decomposition — AgentEngine broken into 6 delegate components (PromptAssembler, CalibrationManager, SkillDispatcher, SessionPersistence, LearningBridge, ToolDispatchEngine) and 5 sub-packages (recovery/, context/, task_planning/, tools/, session/).
  • Context sub-package consolidation — context_compressor, context_control, context_disclosure, context_focus, and reference_resolver relocated under engine/context/.
  • Message/stream/tool helpers extracted — _message_helpers.py, _stream_helpers.py, _tool_helpers.py split out of the monolithic engine to enforce single-responsibility.
  • Test suite restructure — layered coverage map, shared helpers, perf regression bounds, sync fixture tooling.

Enhance

  • Scheduler UX — /schedule cancel now routes through coordinator for cloud tasks; execution mode displayed in status output; structured logs queryable per task.
  • Provider chain resilience — credential pool rotation, provider-context handoff, compression-provider isolation.
  • Prompt assembler — cache-boundary annotations, prefix-stability layout validation, volatile-context separation.
  • Dashboard — subagent panel, app.js interaction improvements.
  • AGENTS.md — added token efficiency, prefix cache stability, and system prompt template anchor rules.

Fix

  • Scheduler — ok=False with max_retries=0 now correctly marks task FAILED instead of silently swallowing.
  • /btw — explicitly disables tools and thinking to prevent accidental tool invocation in side-questions.
  • /schedule cancel — routes through coordinator so cloud-scheduled tasks are properly cancelled.
  • DeepSeek thinking mode — resolved 400 error on tool round-trip by sanitizing reasoning content.
  • TUI Markdown rendering — angle-bracketed identifiers in Python tracebacks no longer silently stripped.

Docs

  • Third-party plugin development guide added under docs/plugins/.
  • AGENTS.md updated with prefix cache stability, template anchor, and engine decomposition rules.

wangxingjun778 and others added 17 commits September 20, 2026 13:10
[MILESTONE] P0 PCD Cache-Aware: all acceptance criteria met (DeepSeek real regression)
  - token-weighted cache hit rate: 84.9% (target >=70%)
  - session resume first-turn cache hit: confirmed
  - compression provider isolation: verified

Subsystem 1 — Cache Boundary & Disclosure:
  - CacheBoundary enum (NONE/SOFT/COMMITTED) in context_disclosure.py
  - PromptAssemblyPlan cache_boundary + stable_tool_names fields
  - DisclosurePlanner cache-aware path (commitment_status/committed_level)

Subsystem 2 — PrefixCommitment Enforcement:
  - CommitmentEnforcement frozen snapshot + enforce/break/force_commit
  - Four break-commitment integration points (posture/tool_error/slash/transform)
  - Two-phase cache optimization (skew fix): evaluate before marker application
  - SOFT boundary activation (projected_savings > 0)
  - min_prefix_tokens threshold: 1024 -> 768 for earlier commitment

Subsystem 3 — Prompt Cache Strategy:
  - PrefixCacheOptimizer boundary-aware: COMMITTED passthrough (byte-stable)
  - AnthropicCacheStrategy static/dynamic system prompt split + tool marker
  - Provider-aware CacheStrategy selection via plugin capability (cache_type)
  - Removed unused cache_ttl parameter

Subsystem 4 — Compression Provider Isolation:
  - Independent compression provider (compression_* settings)
  - summarize_fn routing to dedicated provider
  - Graceful degradation on construction failure

Subsystem 5 — Session Resume Prefix Protection:
  - DuckDB schema v7: session snapshot columns
  - SessionSnapshot read/write API (conversation_store)
  - force_commit on resume with cache_priority/tool_freshness policy

[MILESTONE] Anthropic Native Provider:
  - AnthropicChat provider (AsyncAnthropic, cache_control passthrough)
  - AnthropicPlugin (cache_type=explicit_breakpoint)
  - Optional anthropic SDK dependency with graceful degradation

[MILESTONE] Prefix Stability Optimization:
  - Volatile context (memory/knowledge/focus) separated from stable system prefix
  - Independent system message with _volatile_context marker
  - PrefixCacheOptimizer excludes volatile from stable prefix
  - Result: R1 cold-start hit rate 40.4% -> 96.5% (+56pp)

[MILESTONE] Measurement Caliber Alignment:
  - SessionCacheStats: token-weighted + steady-state + per-turn average
  - format_log_line and to_learning_signal dual-caliber output
  - Configurable steady_state_skip_turns (default=3)

Engineering Quality:
  - Internal marker sanitization (_sanitize_messages in OpenAI provider)
  - Anthropic volatile marker skip (no wasted cache breakpoints)
  - Streaming text path usage telemetry fix
  - Anthropic usage denominator correction (cache_read + cache_creation)
  - 34 files, +6233/-124 lines, 150+ new test cases, 0 regressions

Signed-off-by: 班扬 <xingjun.wxj@alibaba-inc.com>
Two bugs fixed:

1. MessageHealer._close_interrupted_tool_sequence injected a synthetic
   assistant message without reasoning_content during normal tool loops.
   DeepSeek thinking mode requires all assistant messages to carry
   reasoning_content; the synthetic message violated this constraint
   causing a 400 invalid_request_error. Fix: detect valid parent
   assistant(tool_calls) and skip injection when tool sequence is intact.

2. thinking_disable recovery strategy did not actually set
   planned_enable_thinking=False, causing the retry to repeat the same
   400 error. Fix: both non-streaming and streaming loops now properly
   disable thinking on TRANSFORM_AND_RETRY with thinking_disable.

Verified with real DeepSeek API (deepseek-flash): thinking + tool_calls
+ second-round LLM call all succeed after fix.

Signed-off-by: 班扬 <xingjun.wxj@alibaba-inc.com>
…ckages and delegate components

Phase 0: Delete dead stubs (resilience.py, terminal_io.py)
Phase 1: Reorganize 28 files into 5 sub-packages (recovery/, context/, task_planning/, tools/, session/)
Phase 2: Extract 43 free functions into _message_helpers, _tool_helpers, _stream_helpers
Phase 3: Extract 5 delegate components (PromptAssembler, CalibrationManager, SkillDispatcher, SessionPersistence, LearningBridge)
Phase 4: Unify streaming/non-streaming paths via OutputSink abstraction
Phase 5: Extract ToolDispatchEngine (22 tool execution methods)
Phase 6-7: Fix Critical/High issues, add engine module architecture rules to AGENTS.md

engine.py: 7482 -> 2539 lines (-66%), 228 -> 86 methods (-62%)
Tests: 4239 passed, 0 non-journey failures, 90/90 architecture contracts pass

Signed-off-by: 班扬 <xingjun.wxj@alibaba-inc.com>
Split the monolithic agent execution tests into focused modules, add 166 direct unit tests for engine delegate components, harden incident ledger checks, and introduce an opt-in live LLM CI lane with strict token, call, and deadline budgets.

Signed-off-by: 班扬 <xingjun.wxj@alibaba-inc.com>
Add focused tests for configuration, security actions, daemon coordinators, learning, signal fusion, and live token budgets. Fix nearest-event fusion matching, add coverage reporting, refresh the impact map, and provide safe cassette diagnostics.

Signed-off-by: 班扬 <xingjun.wxj@alibaba-inc.com>
Rich Markdown silently strips <string>, <module>, <stdin> etc. from
tracebacks, making error diagnostics unreadable. Escape them as inline
code before rendering. Add AGENTS.md rule for tool output integrity.

Signed-off-by: 班扬 <xingjun.wxj@alibaba-inc.com>
Codify prompt cache hit rate protection: system prompt anchor contracts,
prefix commitment lifecycle, compression frozen-segment invariant, provider
cache metric propagation, and session resume cache policy end-to-end rule.

Signed-off-by: 班扬 <xingjun.wxj@alibaba-inc.com>
Facade plugin aggregating registry, daemon, engine, and build_info into
faceted self_describe and lightweight runtime_snapshot tools. Registry
version gate and TTL caching keep data current without hot-path cost.
CORE-tier PCD whitelist ensures the agent can always introspect.

Signed-off-by: 班扬 <xingjun.wxj@alibaba-inc.com>
…curator, scheduler

- feat(engine): add /btw side-question fiber with cache-parity isolation
- feat(cli): unified leap doctor with 5-domain diagnostic checks
- feat(engine): BM25 tool search with budget-driven progressive disclosure
- feat(skills): skill curator MVP with active/stale/archived lifecycle
- feat(scheduler): productize execution mode unification and UX
- fix(scheduler): ok=False with max_retries=0 now correctly marks FAILED
- fix(engine): /btw explicitly disables tools and thinking
- fix(scheduler): /schedule cancel routes through coordinator for cloud tasks
…asks

/btw was entering the command queue and showing '#2 queued' instead of
executing concurrently. Add a side-command bypass in submit_text() that
creates an asyncio.Task for SideQuestionFiber, allowing immediate
execution while the main task continues.

Signed-off-by: 班扬 <xingjun.wxj@alibaba-inc.com>
…on-ops, compression-timeout, memory-nudge

- feat(security): Guardian LLM intelligent approval with DenialBreaker circuit breaker
- feat(engine): StreamingThinkScrubber for reasoning content filtering
- feat(storage): session archive/pin/hide operations with /session CLI commands
- feat(recovery): compression timeout ladder strategy (60s/300s/900s cooldown tiers)
- feat(memory): periodic memory nudge policy with EventBus integration
- fix(security): Guardian as optional enhancement, static rules remain first defense
- fix(engine): ScrubberSink adapts to real OutputSink Protocol interface
@wangxingjun778
wangxingjun778 merged commit 576de99 into main Sep 22, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants