Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit History
-
[codex] Harden agent prompt guidance (#331)
Unverified signature* Harden agent prompt guidance Co-authored-by: OpenAI Codex <codex@openai.com> * Handle streaming LLM read timeouts Co-authored-by: OpenAI Codex <codex@openai.com> * Address autonomous prompt review feedback Co-authored-by: OpenAI Codex <codex@openai.com> * Address prompt review comments Co-authored-by: OpenAI Codex <codex@openai.com> * Address reviewer feedback on prompt guidance Co-authored-by: OpenAI Codex <codex@openai.com> * Stop activation from resetting usage windows Co-authored-by: OpenAI Codex <codex@openai.com> * Harden ML dependency freshness guidance Co-authored-by: OpenAI Codex <codex@openai.com> * Constrain kernels dependency guidance Co-authored-by: OpenAI Codex <codex@openai.com> * Exclude T4 for flash attention kernels Co-authored-by: OpenAI Codex <codex@openai.com> * Use shell-safe kernels dependency spec Co-authored-by: OpenAI Codex <codex@openai.com> --------- Co-authored-by: OpenAI Codex <codex@openai.com>ece0775
-
Enforce YOLO cap across session usage (#313)
Unverified signature* Enforce YOLO cap across session usage Co-authored-by: OpenAI Codex <codex@openai.com> * Address YOLO budget review feedback Co-authored-by: OpenAI Codex <codex@openai.com> * Switch YOLO LLM cap checks to post-call warnings Co-authored-by: OpenAI Codex <codex@openai.com> * Improve YOLO cap reached CTA Co-authored-by: OpenAI Codex <codex@openai.com> * Fix YOLO blocked approval flow Show cap extension controls for pre-execution budget blocks and preserve approved tool parts during approval continuation streams. Co-authored-by: OpenAI Codex <codex@openai.com> * Sync usage meter with YOLO ledger Co-authored-by: OpenAI Codex <codex@openai.com> * Fix YOLO usage accounting drift Co-authored-by: OpenAI Codex <codex@openai.com> * Emit YOLO updates for observed spend Co-authored-by: OpenAI Codex <codex@openai.com> * Handle YOLO updates in active chat stream Co-authored-by: OpenAI Codex <codex@openai.com> * Reconcile YOLO ledger from usage fetches Co-authored-by: OpenAI Codex…d76b37c -
Use session billing endpoint for inference usage (#314)
Unverified signature* Use session billing endpoint for inference usage Replace current-session inference billing estimates with the Hugging Face session usage endpoint and ensure HF Router requests carry session IDs across providers. Co-authored-by: OpenAI Codex <codex@openai.com> * Rotate inference billing session IDs Co-authored-by: OpenAI Codex <codex@openai.com> * Address session billing review feedback Co-authored-by: OpenAI Codex <codex@openai.com> * Send Router billing session ID header Co-authored-by: OpenAI Codex <codex@openai.com> * Fix duplicate streamed assistant text Co-authored-by: OpenAI Codex <codex@openai.com> --------- Co-authored-by: OpenAI Codex <codex@openai.com>9e28f0f
-
Implement user-billed model policy (#289)
Unverified signature* Implement user-billed model policy - bill hosted inference to user tokens and remove subsidy quota state - switch web and CLI defaults and remove Sonnet from model lists - add plan-aware inference credit CTAs Co-authored-by: OpenAI Codex <codex@openai.com> * Recommend Opus in model picker Co-authored-by: OpenAI Codex <codex@openai.com> * Remove minimum plan from model config Co-authored-by: OpenAI Codex <codex@openai.com> * Link message failures to Space discussions Co-authored-by: OpenAI Codex <codex@openai.com> * Remove compatibility quota endpoint Co-authored-by: OpenAI Codex <codex@openai.com> * Remove obsolete bill_to_user argument Co-authored-by: OpenAI Codex <codex@openai.com> * Remove model tier metadata Co-authored-by: OpenAI Codex <codex@openai.com> * Remove model picker provider subtitles Co-authored-by: OpenAI Codex <codex@openai.com> --------- Co-authored-by: OpenAI Codex <codex@openai.com>ded9881
-
Restore prompt caching for FAL router models (#286)
Unverified signature* Restore prompt caching for FAL router models Co-authored-by: OpenAI Codex <codex@openai.com> * Tune prompt caching hints for GPT-5.5 Co-authored-by: OpenAI Codex <codex@openai.com> * Address backlog prompt caching import review Co-authored-by: OpenAI Codex <codex@openai.com> --------- Co-authored-by: OpenAI Codex <codex@openai.com>e6f00a2
-
Route LLM inference through HF Router (#282)
Unverified signature* Route LLM inference through HF Router Co-authored-by: OpenAI Codex <codex@openai.com> * Address HF router PR review Co-authored-by: OpenAI Codex <codex@openai.com> * Address router cleanup review Remove no-op prompt caching and reasoning replay paths, genericize router model handling, and update docs/tests for HF Router-only setup. Co-authored-by: OpenAI Codex <codex@openai.com> * Fix READEM --------- Co-authored-by: OpenAI Codex <codex@openai.com>437a804
-
Enable FAL endpoint to lift limits (#278)
Unverified signature* Bill premium models through the HF router on the user's HF account Route Claude Opus 4.6 and GPT-5.5 off Bedrock/native APIs onto the HF Inference Router (huggingface/anthropic/claude-opus-4.6:fal-ai and huggingface/openai/gpt-5.5:fal-ai). The same daily allowance as before (free=1, pro=20) stays company-subsidized via INFERENCE_TOKEN; once a user is past it, the session's premium_user_billed flag flips and the call bills the user's own HF OAuth token (no X-HF-Bill-To) instead of returning the old 429 cap. - llm_params: bill_to_user routes premium (anthropic/ + openai/) router calls to the user's token; free models stay subsidized. - premium_user_billed is persisted/restored and threaded through the main loop, context compaction, the research sub-agent (now downgraded to router Sonnet 4.6), and effort probes. - Frontend: per-session BillingBanner (dismissible daily); remove the now unreachable ClaudeCapDialog + 429 quota-exhausted plumbing; the model chip shows "Billed" p…c9a83ae
-
Add `/clear` and `/new` commands (#256)
Unverified signature021580f
-
Add CI for tests and Ruff (#217)
Unverified signature* Add CI for tests and Ruff Co-authored-by: OpenAI Codex <codex@openai.com> * Enforce Ruff formatting in CI Co-authored-by: OpenAI Codex <codex@openai.com> * Document Ruff pre-commit checks Co-authored-by: OpenAI Codex <codex@openai.com> --------- Co-authored-by: OpenAI Codex <codex@openai.com>754345f -
Stop attaching timestamps to LLM messages (#209)
Unverified signature* Strip internal message metadata before LLM calls Co-authored-by: OpenAI Codex <codex@openai.com> * Simplify timestamp handling for provider messages Co-authored-by: OpenAI Codex <codex@openai.com> * Remove timestamp metadata regression test Co-authored-by: OpenAI Codex <codex@openai.com> --------- Co-authored-by: OpenAI Codex <codex@openai.com>93d536c -
fix(compaction): break infinite loop + truncate oversized messages (#213)
Guillaume SalouUnverified signature* fix(compaction): break the infinite-compaction loop, truncate oversized messages Sessions stuck in a compaction retry loop have been silently burning Bedrock budget while staying invisible in the session dataset. Pod logs from 2026-05-03 on prod-114 showed the pattern firing minute-after-minute on multiple replicas: Context compacted: 200001 -> 215566 tokens Context compacted: 215566 -> 215572 tokens ContextWindowExceededError — forcing compaction Context compacted: 200001 -> 215544 tokens ... Root cause: a single message in the "untouched" tail (typically a tool output of 80k+ tokens — bash dump, file content, CSV) keeps the post-compact context above the 90% threshold. Compaction triggers again, calls Bedrock again, gets the same 215k result, loops. ~$3 per Opus retry, indefinitely. Sessions never reach _run_session.finally → save_and_upload_detached never fires → cost is real but never lands in total_cost_usd. Cross-check: dataset Bedrock-only coverage on 2026-05-01 …d84b454
-
Auto-share session traces to a private HF dataset (#193)
Darshan Thakare +2: lewtun, Codex Unverified signature* feat: add share_traces toggle and per-user trace repo template * feat: support Claude Code JSONL format and per-target auth * feat: dual-upload sessions to private user trace dataset * chore: retry personal trace uploads on booting * feat: add /share-traces command to flip dataset visibility * docs: document HF trace auto-share and /share-traces * Use HF token owner for local dev auth Co-authored-by: Codex <codex@openai.com> * Rename personal session trace dataset Co-authored-by: Codex <codex@openai.com> * Add session dataset card metadata Co-authored-by: Codex <codex@openai.com> * Fix session trace upload review issues Co-authored-by: OpenAI Codex <codex@openai.com> * Preserve secret scrubbing before trace uploads Co-authored-by: OpenAI Codex <codex@openai.com> * Link ML Intern demo in dataset card Co-authored-by: OpenAI Codex <codex@openai.com> --------- Co-authored-by: lewtun <lewis.c.tunstall@gmail.com> Co-authored-by: Codex <codex@openai.com>0bd7547
-
feat(telemetry): track 5 untracked Bedrock call sites for full cost attribution (#179)
Guillaume SalouUnverified signature* feat(telemetry): track 5 untracked Bedrock call sites for full cost attribution Cost Explorer ($78,738 over 6 days) vs the session dataset's total_cost_usd (~$354/day attributed) showed the dataset captures only ~33% of real Bedrock spend. Root cause: out of 9 acompletion() call sites, only 2 (in agent_loop.py) emit the llm_call event that total_cost_usd sums. This wires telemetry into the 5 Bedrock-billing call sites that were flying blind, with a `kind` tag on each call so analytics can split spend by category: - research_tool.py × 3 → kind="research" (sub-agent loop) - context_manager.py → kind="compaction" (history summary) - effort_probe.py → kind="effort_probe" (cascade walk) Plus a fourth tag for the session-restore summary path (session_manager.py → kind="restore"). Plumbing changes: - telemetry.record_llm_call now accepts kind="..." (default "main" preserves existing behavior). - summarize_messages() and ContextManager.compact() take optional ses…7867a7a
-
Persist Space sessions in MongoDB (#170)
Aksel Joonas ReediUnverified signature* Persist Space sessions across backend restarts The hosted Space lost active conversations because sessions, approval state, event streams, and Claude quotas only lived in process memory. This adds a shared optional Mongo store for frontend sessions while keeping local and CLI runs on the no-op/local path when Mongo is absent. Constraint: Space deployment needs durable state without making PyPI/local CLI users configure Mongo. Constraint: Frontend deletes must hide sessions with a visibility tag, not erase traces needed for recovery or SFT export. Rejected: Restore every active session at startup | large user counts would create a thundering herd after deploys. Rejected: Store one giant session document | Mongo document limits make per-message snapshot docs safer. Confidence: medium Scope-risk: broad Directive: Keep session_messages as compactable runtime snapshots and session_trace_messages/session_events as append-only raw traces; do not collapse them into one collection wit…d9d9785
-
Fix CLI rendering corruption and split CLI/frontend model defaults (#121)
Aksel Joonas ReediUnverified signature* Stabilize CLI rendering and make surface defaults explicit The interactive CLI was interleaving live sub-agent redraws with streamed markdown output, which corrupted ANSI rendering and leaked raw control sequences into the terminal. The CLI and web app also shared one default model config even though they need different Anthropic routing defaults. Constraint: CLI default must use direct Anthropic credentials while web sessions must default to Bedrock Anthropic Constraint: Interactive terminal output must remain readable while sub-agent progress is live Rejected: Single shared config file with runtime overrides | keeps ownership of defaults implicit across surfaces Rejected: Keep background redraw ticker | concurrent terminal writers still corrupt streamed output Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep CLI and frontend default models in separate config files unless both surfaces intentionally converge again Tested: python -m compileall agent backen…3eec386
-
feat: enable Anthropic prompt caching on system prompt and tools (#69)
Unverified signature* feat: enable Anthropic prompt caching on system prompt and tools Mark the rendered system prompt and the tool block with cache_control breakpoints when calling Anthropic models. The static prefix (~4-5K tokens of system prompt + 15+ tool definitions) was being re-billed at full input rate on every turn, every retry, and every research sub-agent iteration (up to 60 per task). With ephemeral cache breakpoints, subsequent turns within the 5-minute TTL are billed at cache-read pricing (~10% of input cost). Expected savings: 40-50% input tokens on multi-turn conversations, 60-80% on research sub-agent loops. Caching is GA in the Anthropic API and natively supported by litellm 1.83+ via cache_control blocks (no beta header required). Non-Anthropic models (HF router, OpenAI) are passed through unchanged. The helper does not mutate the caller's message list or tool list, so the persisted ContextManager.items history stays in its original string-content form. * refactor: hoist prompt_cac…5d357ba
-
Restore expired sessions via summary-based catch-up (#52)
Aksel Joonas ReediUnverified signatureWhen the backend loses a session (typically: HF Space restarted), the chat now shows a small inline banner instead of silently erroring: Where were we? Let me skim the conversation so far and pick up right where we left off — or we can start something new. [ Catch me up ] [ Start fresh ] Flow, in one pass: * Frontend stashes the raw backend messages in localStorage on every mount-hydrate and turn_complete. When the backend 404s for the session id, the SSE transport and the mount effect both fire onSessionDead → the session is flagged `expired` in sessionStore; the sidebar marks it "needs a catch-up". * Catch me up → POST /api/session/restore-summary with the cached messages. Backend creates a fresh session, runs the existing summarizer (factored into summarize_messages() and shared with in-session compaction) with a restore-specific prompt that preserves the tool-call trail, and seeds the new session with that summary wrapped in a [SYS…962191f -
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 -
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
-
Add message edit and regenerate from any point in conversation
Backend: add truncate_to_user_message() on ContextManager, POST /api/truncate/{session_id} endpoint, and session_manager.truncate() helper to slice conversation history to before a given user message. Frontend: add editAndRegenerate callback in useAgentChat that truncates backend + frontend messages then resubmits via existing chat flow. UserMessage gains an inline edit mode with pencil icon on hover, TextField for editing, Enter/Escape to confirm/cancel.0611031 -
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 -
refactor: append dynamic session context after static system prompt for cache stability
3ed5324 -
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 -
fix: also skip plan_tool from deterministic pruning
Research and plan_tool outputs are critical for task continuity across compaction — they should never be truncated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>e561d10 -
fix: skip research tool outputs in deterministic pruning
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>c130bba -
Add deterministic pruning of old tool outputs before LLM compaction
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>64437d0
-
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
-
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: protect system prompt in undo, scan backwards for dangling tool calls, gate input on SDK status
a13e8cc -
fix: patch dangling tool calls on error, move undo to context manager
a1ce5bc
-
fix: improve compaction summary prompt, remove sidebar status bar
13ae315
-
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: restore sandbox tools and proactive compaction
a644598 -
feat: merge HF Space improvements
79b2fcc
-
v3 prompt and tool desc rework
66647c8 -
adding compaction
369d828
-
frontend update
463e470
-
adding whoami to system prompt
d9a3b65
-
integrated hf skills into the prompts
6735687
-
loading date in system prompt, search code update (still not there)
64a9ca9
-
Added tools to create repos, view them, upload files to them (private). added a clock tool.
Henri Bonamy82baf19
-
added the explore subagent, quality ok but not perf
b6155b0
-
Fixed assistant -> assistant messages after compaction
Henri Bonamya3268b6 -
prompt update and loading from file
5099f9d
-
prompt change
Henri Bonamy579e839
-
added compaction every x tokens
Henri Bonamy8c943c2