feat(subagents): cache-aware resident file sub-agents for refactors (closes #529)#660
feat(subagents): cache-aware resident file sub-agents for refactors (closes #529)#660merchloubna70-dot wants to merge 4 commits into
Conversation
All system prompts were English-only, causing DeepSeek V4 to reason and respond in English even when users wrote in Chinese or other languages. Add a Language Mirror section to base.md and base.txt that instructs the model to detect the user's primary language and use it for both reasoning (thinking tokens) and the final reply.
base.txt is not referenced via include_str! in prompts.rs. Only base.md is loaded (BASE_PROMPT). Remove the redundant change to base.txt as noted by Gemini Code Assist review.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
谁家PR机器人 |
Review notes from v0.8.12 integrationReviewed the cache-aware resident file sub-agents as part of merging into v0.8.12. One finding: Lease table has no cleanupThe global ownership table ( if let Some(owner) = guard.get(file_path) {
Some(format!("Warning: agent {owner} already holds a resident lease on {file_path}"))
} else {
guard.insert(file_path.to_string(), agent_id.clone());
None
}But the lease is never released. Not on agent completion, not on crash, not on cancellation. The only way to clear a lease is to restart the TUI. This means: spawn an agent on RecommendationHook into the agent lifecycle to release leases on terminal states (completed, failed, cancelled). The sub-agent manager's cleanup path is the right place — when an agent transitions to a terminal status, walk its leases and remove them. |
|
@Hmbown Correct — the lease is never released, which makes resident mode unusable for repeated work on the same file. This is a real bug. Fix: hook into the agent's terminal state transition to remove the lease. The right place is wherever the sub-agent manager marks an agent as completed/failed/cancelled. I'll push the fix to the PR branch now. The approach:
|
v0.8.12 fix appliedThe lease cleanup leak has been fixed on
Previously, leases were acquired on spawn but never released, causing false conflict warnings when respawning on the same file. Now the file is immediately available after an agent finishes. Commit: Remaining issue: The lease acquisition inserts |
…Hmbown#660) After spawning a resident-file sub-agent, the lease table held "pending" as the owner placeholder. Conflict warnings for the same file on the next spawn showed "agent pending already holds a lease" instead of the actual agent nickname. Update the placeholder to the real agent_id immediately after spawn_background_with_assignment_options succeeds. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
60e4fc9 to
4bad077
Compare
|
Fixed the remaining issue — after |
47 fmt drifts had accumulated from the squash-merged community PRs on this branch (#653, #654, #655, #645, #658, #668, #659, #661, #660, #667, #656). Pure formatting — no behavioural changes — applied via `cargo fmt --all` to satisfy CI's `cargo fmt --all -- --check` gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
#660) Resident-file leases were stamped as "pending" at spawn time because the agent id is only assigned by the manager later. The release function introduced in 2ee926924 matches by agent id, so it could never find those entries and leases would persist for the lifetime of the process. After spawn returns the real agent id, replace any "pending" entry with it so the existing release-on-terminal-state path actually fires. Resolves the documented v0.8.12 caveat noted in the CHANGELOG. Closes the loop with PR #694, which proposed a release-by-file-path API but did not address the placeholder problem itself. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…own#660) Moved RESIDENT_LEASES from block-scoped static to module level so the release function can access it. Added release_resident_leases_for() called at all three terminal transitions: - Cancelled (cancel_agent) - Failed (update_failed) - Completed (run_subagent_turn result construction) Previously leases were acquired but never released, causing false conflict warnings on subsequent spawns targeting the same file.
…own#660) Moved RESIDENT_LEASES from block-scoped static to module level so the release function can access it. Added release_resident_leases_for() called at all three terminal transitions: - Cancelled (cancel_agent) - Failed (update_failed) - Completed (run_subagent_turn result construction) Previously leases were acquired but never released, causing false conflict warnings on subsequent spawns targeting the same file.
47 fmt drifts had accumulated from the squash-merged community PRs on this branch (Hmbown#653, Hmbown#654, Hmbown#655, Hmbown#645, Hmbown#658, Hmbown#668, Hmbown#659, Hmbown#661, Hmbown#660, Hmbown#667, Hmbown#656). Pure formatting — no behavioural changes — applied via `cargo fmt --all` to satisfy CI's `cargo fmt --all -- --check` gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Hmbown#660) Resident-file leases were stamped as "pending" at spawn time because the agent id is only assigned by the manager later. The release function introduced in 2ee926924 matches by agent id, so it could never find those entries and leases would persist for the lifetime of the process. After spawn returns the real agent id, replace any "pending" entry with it so the existing release-on-terminal-state path actually fires. Resolves the documented v0.8.12 caveat noted in the CHANGELOG. Closes the loop with PR Hmbown#694, which proposed a release-by-file-path API but did not address the placeholder problem itself. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This PR was opened before the v0.8.41 rebrand and is now stale. Feel free to rebase onto current |
Adds
resident_fileparameter toagent_spawn. Child prompt is prefixed with file contents for byte-stable prefix caching. Ownership table prevents two agents leasing the same file simultaneously. Closes #529wangfengcsu@qq.com