Skip to content

[Enhancement] Long-horizon tasks enhancement - #38

Merged
wangxingjun778 merged 11 commits into
mainfrom
feat/stream_loop
Aug 12, 2026
Merged

[Enhancement] Long-horizon tasks enhancement#38
wangxingjun778 merged 11 commits into
mainfrom
feat/stream_loop

Conversation

@wangxingjun778

Copy link
Copy Markdown
Member

No description provided.

When LLM calls code_search without pattern (intending to browse files),
the error now explicitly guides it to use file_list instead. Tool
description also clarified to prevent tool-selection confusion.
session_search (and other dynamically registered tools) were correctly
disclosed to the LLM in TOOL_DEFINITIONS but failed name resolution
because TOOL_REGISTRY was frozen at import time. Now _default_tool_registry()
cache-invalidates and rebuilds when TOOL_DEFINITIONS or TOOL_HANDLERS grow,
ensuring runtime-registered tools resolve correctly.
LLM frequently calls shell_list/shell_open/shell_send/shell_read/shell_close
when it means terminal_list/terminal_open etc. Add static aliases so these
resolve correctly without hitting the 'Unknown tool' path.
…s entirely

_is_bypass_active() now checks both config-level (approval_bypass) and
session-level (SessionAwareGate._bypass_all from 'Allow ALL for this session').
When either is true, workspace boundary checks AND dangerous command approval
are skipped entirely — no orchestrator round-trip needed. Hardline patterns
(rm -rf /, mkfs, etc.) remain blocked unconditionally upstream.
LLM repeatedly calls code_search with only path (intending to browse files).
Instead of returning an error that the LLM retries or gives up on, now
gracefully redirect to file_list(path, depth=2). Also removed pattern from
required in schema so engine-level validation doesn't reject it first.
_normalize_decision() had a hardcoded allowed-set that predated the
ALLOW_ALL_SESSION enum value. The user's selection was being silently
converted to 'deny', so SessionAwareGate._bypass_all was never set.
…th spiral

P0: Fix false progress detection + hard-gate repeated reads
- evidence_count only increments for genuinely new source paths
- _task_progress_marker includes repeated_reads count as negative signal
- File reads beyond repeated_read_limit return summary instead of content
- Write-then-read exception: edit resets read count for that path

P1: Periodic checkpoint forcing + research ledger capacity expansion
- New agent_checkpoint_interval config (default 15 rounds)
- checkpoint_notice() forces intermediate deliverable in research posture
- Research ledger: 200→600 chars/note, 24→32 items, 16K total cap with FIFO

P2: Large-task strategy guidance + pre-compression knowledge extraction
- _LARGE_TASK_PROTOCOL injected for complex tasks (decompose, search, record)
- _auto_extract_findings() captures file paths and key content before compression
- Extracted findings auto-injected into research ledger post-compression
- Fix runtime NameError: _research_protocol_for and _auto_extract_findings
  referenced non-existent 'LeapFlowEngine' class name (should be AgentEngine)
- Fix _is_bypass_active: penetrate SmartApprovalGate._delegate wrapper
  to detect session-level bypass correctly in all configurations
- Fix research ledger: _enforce_total_capacity truncates _next_step as
  last resort when no list buckets remain but total chars exceeds limit
Per AGENTS.md anti-hardcoding principle:

1. _research_protocol_for(): remove architecture_tokens and _large_task_keywords
   keyword tuples. Selection now driven by input length (structural numeric
   signal) with configurable threshold, not keyword scanning.

2. _tool_focus_metadata(): prefer ToolSpec.context_plane from registry manifest;
   name-based inference demoted to deprecated fallback with log warning.

3. _auto_extract_findings(): replace '"ok": false' substring sniffing with
   proper JSON parsing for robustness.

4. Error classification: prefer structured failure_code over string matching;
   substring check retained as compat fallback with TODO for removal.
P0: Enable cross-session memory recall
- Remove session_scope filter from _prefetch_and_freeze_memory() so BM25
  search can retrieve entries from any past session
- Upgrade PCD CORE level from MemoryDisclosure.NONE to SESSION_SUMMARY
  so even simple queries get basic memory context

P1: Automatic session summary generation + proactive history injection
- _generate_session_summary(): heuristic extraction of goal/tools/outcome
  at session end, persisted as SESSION_SUMMARY kind in DuckDB
- _prefetch_and_freeze_memory() Layer 0: injects last 5 session summaries
  into memory context at session start
- SemanticMemoryProvider.query_recent_summaries() for efficient retrieval
- Session title updated to descriptive summary on end

P2: System prompt guidance + session title improvement
- Guidelines added: use session_search for past task recall
- end_session() accepts optional title parameter for descriptive updates
- Fix session summary not reaching DuckDB: MemoryManager.insert() routes
  SESSION_SUMMARY to narrative provider (MEMORY.md), but query_recent_summaries()
  reads from DuckDB. Added explicit semantic.insert() to ensure cross-session
  retrieval works.
- Increase message fetch limit to 200 for better last_assistant extraction
- Deserialize metadata JSON in query_recent_summaries() return values
- Add logger.debug for Layer 0 task history injection failures
@wangxingjun778
wangxingjun778 merged commit f00d5af into main Aug 12, 2026
5 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.

1 participant