Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

Update AGENTS.md env and pytest instructions

Abi Raja54f6dd573644
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 00000000..caca0572
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,18 @@
+# Project Agent Instructions
+
+Python environment:
+
+- Always use the backend Poetry virtualenv (`backend-py3.10`) for Python commands.
+- Preferred invocation: `cd backend && poetry run <command>`.
+- If you need to activate directly, use Poetry to discover it in the current environment:
+ - `cd backend && poetry env activate` (then run the `source .../bin/activate` command it prints)
+
+Testing policy:
+
+- Always run backend tests after every code change: `cd backend && poetry run pytest`.
+
+Additional checks based on what you changed:
+
+- Frontend: `cd frontend && yarn lint`
+
+If changes touch both, run both sets.
diff --git a/design-docs/agentic-runner-refactor.md b/design-docs/agentic-runner-refactor.md
new file mode 100644
index 00000000..cb173452
--- /dev/null
+++ b/design-docs/agentic-runner-refactor.md
@@ -0,0 +1,54 @@
+# Agentic Runner Refactor Spec
+
+## Goals
+- Reduce duplicated streaming logic across OpenAI/Anthropic/Gemini runners.
+- Centralize tool schemas and telemetry formatting.
+- Make the agentic pipeline easier to test, extend, and reason about.
+
+## Decision: Unified Stream Loop + Provider Adapters
+- Introduce a provider-agnostic stream loop that consumes normalized events
+ (assistant_delta, thinking_delta, tool_call_delta, tool_call_complete, done).
+- Add per-provider adapters that translate native streams into normalized events.
+- Centralize tool execution, `toolStart`/`toolResult` emission, and `setCode` preview
+ streaming inside the unified loop.
+- Keep per-provider adapters small and focused on parsing provider-specific payloads.
+
+## Decision: Canonical Tool Definitions + Serializer Layer
+- Define tool schemas once in a canonical representation.
+- Add serializer helpers to produce OpenAI Responses, Anthropic, and Gemini tool
+ schemas from the canonical form.
+- Centralize tool input/output summaries to keep UI telemetry consistent across
+ providers and reduce duplication.
+
+## Planned Removals
+
+### Image Cache
+- Remove prompt-to-URL image caching in the agentic tool layer.
+- Rationale: simplify state, reduce hidden cross-variant coupling.
+- Follow-up: ensure image generation remains deterministic per request when needed
+ (e.g., pass explicit seeds or expose caching at a higher layer if required).
+
+### OpenAI ChatCompletion Path
+- Remove the legacy ChatCompletion streaming path.
+- Route all OpenAI models through the Responses API implementation.
+- Update model lists and runtime checks to eliminate the ChatCompletion branch.
+
+### Non-Agentic Generation Paths (e.g., Video)
+Keep video generation, but route it through the agentic runner:
+- Replace video-specific streaming helpers with agentic runner support for video inputs.
+- Remove conditional branches that bypass the agentic path for video create/update.
+- Preserve video-specific prompt and media handling, but integrate it into the
+ agentic tool/stream pipeline.
+- Update tests and docs to reflect a single agentic generation path that
+ supports video inputs.
+
+## File/Module Split
+- `agentic/runner.py`: orchestration + shared stream loop.
+- `agentic/streaming/`: provider adapters (openai, responses, anthropic, gemini).
+- `agentic/tools.py`: tool definitions, serialization, and execution.
+- `agentic/state.py`: file state + seeding utilities.
+
+## Non-Goals
+- No functional UX changes beyond the removal items above.
+- No redesign of the frontend agent activity UI; it should continue to consume
+ the same tool/assistant/thinking events.