Spaces:
Sleeping
Sleeping
Commit History
-
Read max context from litellm + compact at 90% (#54)
Aksel Joonas ReediUnverified signature* Read max context from litellm.get_model_info + compact at 90% The local _MAX_TOKENS_MAP had Claude Opus 4.6 pinned at 200k, triggering compaction at ~20% of its real 1M window. Swap the hand-maintained table for litellm.get_model_info()['max_input_tokens'], which LiteLLM keeps in sync upstream (Opus 4.6=1M, GPT-5=272k, Sonnet 4.5=200k, etc.). HF router-only ids (MiniMax, Kimi, GLM) aren't in litellm's catalog and fall through to the 200k default — close enough to their advertised ranges and safe if the model lies. Also shifts compaction to fire at 90% of max_context instead of >100%. The old condition waited until context had already overshot, risking the next LLM call hitting ContextWindowExceededError before the compact finished. 90% gives headroom for the summary call + one more turn. * Drop the legacy -10k buffer — the 90% ratio is the headroom now ContextManager was subtracting a fixed 10k tokens from max_context on top of the new 90% compaction threshold, so a 1M-window Opu…28b8f2b -
Fix parallel-research display: per-call stats in CLI and web UI (#49)
Aksel Joonas Reedi +1: lee101 Unverified signatureWhen multiple research sub-agents ran concurrently, the CLI collapsed them into a single flickering slot and every web-UI tool card showed the aggregate across all agents — so 3 parallel calls looked like 1. CLI (agent/utils/terminal_display.py): - Replace the global SubAgentDisplay singleton with SubAgentDisplayManager that tracks each agent by agent_id and renders one block per agent with independent (tool count · tokens · elapsed). - 4 rolling tool-call lines per agent (was 2). - When 2+ agents are live, switch to a compact one-line-per-agent layout (label + stats + most-recent tool). Detailed 4-line rolling view only when a single agent is active. Keeps the live region small enough to fit on one terminal page so cursor-up/erase doesn't drift when content would otherwise scroll into scrollback. - Clip every live-region line to terminal width (ANSI-aware) so a wrapped line can't corrupt the cursor-up math on narrow terminals. - On completion, erase the live block and f…5ab7c4e -
Route HF inference through /v1 auto-router + add reasoning_effort knob
Users paste bare HF model ids (MiniMaxAI/MiniMax-M2.7, moonshotai/Kimi-K2.6) with an optional :fastest|cheapest|preferred|<provider> suffix; the router picks a provider and handles failover. /model does a live preflight against /v1/models and prints providers, pricing, context, tool support — warn-and- allow for unknowns with fuzzy suggestions. Friendly messages replace LiteLLM's raw traceback for model/provider mismatches, and the noisy 'Give Feedback' banner is suppressed. Adds a reasoning_effort config + /effort command (default high). OpenAI and Anthropic get the top-level param natively; HF router gets it via extra_body with minimal->low normalization for models like MiniMax M2 that require reasoning. Frontend + backend model selectors updated to the bare-id format.0a9e96d
-
Fall back to user HF token for router when INFERENCE_TOKEN is unset (#39)
Aksel Joonas Reedi +1: Claude Opus 4.7 (1M context)Unverified signatureThe HF router code path only read INFERENCE_TOKEN, which is the shared server-side key set on the hosted Space so inference is free for users. On the CLI / self-hosted path that env var is absent, so requests went out with no bearer token and the router returned 401 — surfaced to users as "Authentication failed" even with a valid HF_TOKEN (issue #36). Resolve api_key in this order: 1. INFERENCE_TOKEN env (unchanged Space behavior — shared billing) 2. session.hf_token (user's OAuth / CLI token) 3. HF_TOKEN env (belt-and-suspenders for CLI) Applied to _resolve_hf_router_params, research_tool._resolve_llm_params, and ContextManager.compact. Fixes #36 Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>182ddee
-
Refactor approval handling and enhance markdown table styles
4501765
-
Improve agent loop, tools, and research subagent for long-running autonomous tasks
- Add --no-stream and --max-iterations CLI flags for headless operation - Simplify context manager: remove staged pruning, track actual token usage - Add doom-loop detection and context budget to research subagent - Improve file tools: better enforcement, error messages, descriptions - Improve bash tool: longer timeouts, background execution guidance - Add training logging and HP sweep guidance to system prompt - Relax Python requirement to >=3.11 - Remove unused file_content_cache73882d9
-
feat: add headless CLI mode with local filesystem tools and rich terminal rendering
- Add argparse-based headless mode: `python -m agent.main "prompt here"` - Local tool specs override sandbox /app references for CLI mode - System prompt injects CLI-specific context (working directory, no sandbox) - Extract streaming/non-streaming LLM call helpers with LLMResult dataclass - Add shimmer thinking animation (truecolor gradient sweep) - Progressive markdown rendering via rich Live display - Clean MCP shutdown sequence, suppress asyncio teardown noise - Add rich dependency to agent extras577ec48 -
feat: LLM-based pruning for complex tool outputs (hf_jobs)
Tools in _LLM_PRUNE_TOOLS get a cheap LLM call (≤600 tokens) that extracts the answer from the raw output, preserving job IDs, metrics, and error messages exactly. Falls back to deterministic truncation if the LLM call fails. Three tool lists now control pruning behavior: - _PRUNE_SKIP_TOOLS: never pruned (research, plan_tool) - _LLM_PRUNE_TOOLS: LLM-summarised (hf_jobs) - Everything else: deterministic 80-char truncation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>d4b1495 -
Add deterministic pruning of old tool outputs before LLM compaction
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>64437d0 -
Add per-tool error limits and per-turn request cap
544a574 -
feat: add doom-loop detection for repeated tool call patterns
Detects when the agent is stuck calling the same tools repeatedly (identical consecutive calls or repeating sequences like A→B→A→B) and injects a corrective prompt to break the cycle.d3bb2d2
-
feat: render cancelled tool state in UI after user interrupt
Send tool_state_change(cancelled) events for in-flight tools so the frontend can flip spinners to a muted "cancelled" state. Keep SSE stream open (don't call chat.stop()) so backend events arrive. Show "What should the agent do instead?" placeholder after cancel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>887da19 -
feat: kill sandbox processes and cancel HF jobs on user interrupt
When the user clicks cancel, long-running sandbox commands and HF jobs now actually stop instead of running to completion in the background. - Sandbox server: track PIDs with Popen, add /api/kill endpoint - Sandbox client: add kill_all() method - HF jobs: track running job IDs in session, cancel on interrupt - Agent loop: cleanup on cancel in both run_agent and exec_approval - exec_approval: add cancellation support (was completely missing) - Sandbox title: set descriptive name instead of inheriting template Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>3c91fc8
-
fix: auto-retry on truncated tool calls + correct activity status on refresh
Agent loop: when finish_reason=length drops tool calls, inject a system hint telling the LLM to use bash heredoc or smaller edits instead, then continue the loop. Also set max_tokens=16384 and emit an error event so the truncation is visible in the UI. Frontend: extract actual tool name from in-progress message parts on hydration instead of hardcoding 'running', which rendered as "Running running" in the activity bar. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>8e63f40 -
fix: live event streaming after reconnection + LiteLLM timeout
Frontend: visibility change handler now re-hydrates messages, opens a live event stream via GET /api/events, and polls messages every 3s to keep the chat in sync. Terminal events trigger a final hydration and clean up both the stream and poll. Backend: add timeout=600 to litellm acompletion() call — long tool-use turns were being killed by the default timeout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>47d6895 -
fix: clear pending_approval before tool execution starts
Moves session.pending_approval = None to right after parsing approval decisions, before tool execution begins. Previously it was cleared after all tools finished, so a page refresh during execution would re-show the approval dialog. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>c2a3f88
-
refactor: simplify tool call validation and make interrupts cancel tool execution
- Handle finish_reason=length by dropping truncated tool calls before they enter context - Single json.loads per tool call instead of 4 redundant parses - Parsed args flow through to approval/execution without re-parsing - Replace recover_malformed_tool_calls (90 lines) with inline validation in agent loop — bad calls get error results, good calls execute - Make tool execution cancellable: asyncio.wait races gather against cancel event so Ctrl+C/frontend interrupt stops immediately instead of waiting for all tools to finish - Keep _patch_dangling_tool_calls as the only safety net in get_messages() for any remaining edge cases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>f03cbf4 -
feat: CLI local mode, slash commands, interrupt support; remove lmnr; frontend fixes
CLI: - Add local tools (bash/read/write/edit) via local_tools.py for CLI mode - Add ToolRouter local_mode to use local tools instead of sandbox - Add slash commands: /help, /undo, /compact, /model, /yolo, /status - Add Ctrl+C interrupt support (single=cancel, double=exit) - Add HF token auto-loading from env/huggingface-cli - Add session_holder for interrupt/model/status access - Add Session.update_model() method Cleanup: - Remove lmnr dependency and all observe/Laminar references - Delete unused logo PNGs Frontend: - Show hardware pricing in tool approval UI - Add sandbox explanation text - Revert bash streaming to panel (caused issues) - Fix setPanelOutput to not force panel view Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>82b0c13
-
fix: correct context_length init and emit tool_call events for malformed calls
- Initialize context_length to max_context (not token-estimate of system prompt) and reserve 10k token buffer to prevent overflows - Emit synthetic tool_call events before tool_output errors for malformed calls so the frontend renders matching dynamic-tool parts288473a
-
fix: handle interrupt during streaming tool calls without corrupting context
When the user clicks interrupt while the LLM is streaming a tool call, the accumulated deltas can have empty IDs and truncated arguments. Previously these got added to the context and caused litellm API errors on the next call. - Add cancellation check inside the streaming loop so we stop early - Drop tool_calls with empty IDs when building from stream deltas - recover_malformed_tool_calls() now strips empty-ID tool_calls from assistant messages as a safety net Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>4eb958e -
fix: recover malformed tool calls instead of crashing session
When the LLM produces malformed JSON in tool call arguments (common with large write calls), the session would crash. Now ContextManager.recover_malformed_tool_calls() sanitizes the JSON, injects an error result telling the agent to retry with smaller content, and the agent loop skips execution of those tools. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>c7899fc
-
fix: properly close SDK message on error, show tool errorText
b22c5f3 -
fix: patch dangling tool calls on error, move undo to context manager
a1ce5bc
-
feat: resolve sandbox file paths and show tool description in status
- Extract resolve_sandbox_script utility in sandbox_tool.py to detect file paths and read content from sandbox via cat - Resolve script paths before sending approval_required event so the frontend receives actual file content for display and editing - Show tool description arg in status chip and activity bar instead of generic "running" / "Running bash" textae24efc -
fix: route all HF token usage through session.hf_token from OAuth
Remove all os.environ.get("HF_TOKEN") fallbacks. Token now flows exclusively through OAuth -> session.hf_token -> tools. - Pass hf_token through Session -> ContextManager -> _get_hf_username - Add session param to docs, repo_files, repo_git handlers - Jobs use HF_ADMIN_TOKEN for creation, user token for job secrets - Remove HF_TOKEN env setup from backend/main.py - Remove module-level username cache (broken for multi-user)33f29a8
-
feat: implement cooperative agent cancellation with cancel button
ecbfd3c
-
feat: restore sandbox tools and proactive compaction
a644598 -
feat: merge HF Space improvements
79b2fcc
-
adding compaction
369d828 -
sandbox working and agent can use it
786b8bc
-
add create sandbox tool
2464c2e
-
log streaming
Henri Bonamyb7bfe6f
-
Add hf_repo_files and hf_repo_git tools
New tools to replace private_hf_repo_tools with comprehensive HF repo management: hf_repo_files (4 ops): - list: List files with sizes - read: Read file content - upload: Upload content (approval required) - delete: Delete files with wildcards (approval required) hf_repo_git (13 ops): - Branches: create_branch, delete_branch, list_refs - Tags: create_tag, delete_tag - PRs: create_pr, list_prs, get_pr, merge_pr, close_pr, comment_pr - Repo: create_repo, update_repo Approval required for destructive/overwriting operations: - hf_repo_files: upload, delete - hf_repo_git: delete_branch, delete_tag, merge_pr, create_repo, update_repobea6687 -
Fix: look for hardware_flavor at top level of tool_args, not nested
ea8fe87 -
Merge configurable-permissions: add confirm_cpu_jobs, auto_file_upload, keep yolo mode
d8e979d
-
fixing logs
990ecba -
Add yolo mode for auto-approving tool calls
f4655f7
-
cleaned comments
Yoan Di Cosmof5e1da2 -
Add auto_file_upload and confirm_cpu_jobs config settings
Yoan Di Cosmo3fa386c
-
subprocess uploading
c60bea4 -
session logging
fa4ba99
-
poc github tools
ccbe2d2 -
Merge branch 'main' into private-repo-tool
Resolved merge conflicts between PR #7 (streamlined architecture) and PR #8 (private repo tools): **Conflicts resolved:** - agent/core/tools.py: Merged all tools (docs, plan, jobs, private_repos, utils) - agent/main.py: Integrated private repo approvals into batch approval system - agent/tools/jobs_tool.py: Kept PR #7 improvements + added hf_private_repos note **Key integration points:** - Private repo operations (create_repo, upload_file) now use same batch approval flow as jobs - Tool ordering: explore_hf_docs → fetch_hf_docs → plan → hf_jobs → hf_private_repos → utils - Jobs tool description includes note about using hf_private_repos for persistent storage Both branches' functionality preserved and integrated.b70fed7 -
made cli able to take in copy pasted things
71477da
-
Added tools to create repos, view them, upload files to them (private). added a clock tool.
Henri Bonamy82baf19 -
reworked job tool descriptions + implemented batch processing for hf_job tool calls in cli
6e51e5b
-
color for output, tool output truncation, plan printing
Henri Bonamy258ab19
-
adding a user approval step to jobs api + ruff formatting
122b05c
-
prompt update and loading from file
5099f9d
-
added compaction every x tokens
Henri Bonamy8c943c2