This file provides implementation and collaboration guidance for coding agents working in this repository.
- Project: welder
- Goal: local-first, transparent AI agent system with file-first memory and observable context management
- Backend: FastAPI + LangChain 1.x (
create_agent) + OpenAI-compatible model interface - Frontend: Next.js 14 + TypeScript + Tailwind + Monaco
- Runtime ports: frontend
3000, backend8002
Canonical memory paths are under backend/workspace:
backend/workspace/MEMORY.md(long-term memory)backend/workspace/memory/logs/YYYY-MM-DD.md(daily logs)backend/workspace/memory/index/memory.sqlite(retrieval index, acceleration layer only)
Do not introduce new runtime writes to legacy backend/memory/* paths.
Core orchestration lives in:
backend/context/manager.pybackend/context/*helpers (bootstrap.py,pruner.py,flush.py,compactor.py,token_budget.py)
Pipeline order before LLM call:
- load context state
- apply bootstrap limits
- token precheck
- prune aged tool results
- pre-compaction flush when needed
- compaction when needed
- return prepared system prompt + messages
backend/agent/agent_manager.py- Uses LangChain 1.x
create_agent - Supports streaming SSE events:
content,tool_call,complete,error - Handles overflow via compaction+retry
- Persists session + updates long-term memory after assistant response
backend/app.py- File API allowlist roots:
workspace,skills,sessions - Rejects absolute paths and traversal (
..)
- File-first truth: Markdown/JSON are authoritative; SQLite is rebuildable cache.
- Transparency over magic: prefer explicit state/events/logs to hidden behavior.
- Safety first: preserve strict path and command boundaries.
- OpenClaw alignment: keep workspace prompt components concise and ordered.
- Deterministic behavior: avoid brittle regex heuristics for core memory extraction.
uv sync
cd frontend && npm install && cd .../start.shor manually:
uv run uvicorn backend.app:app --reload --port 8002
cd frontend && npm run devcd backend && pytest -q
cd frontend && npx tsc --noEmitREADME.mddocs/TECH_ARCHITECTURE.mdbackend/app.pybackend/agent/agent_manager.pybackend/context/manager.pybackend/memory/memory_manager.pybackend/tools/core_tools.py
- Keep public file API roots unchanged unless explicitly required and reviewed.
- Keep memory extraction LLM-structured and schema-driven.
- If changing context thresholds, update both
context_config.pyand docs. - Preserve SSE event compatibility (
content/tool_call/complete/error). - Update docs (
README.md,docs/TECH_ARCHITECTURE.md, this file) when behavior changes.
backend/context/compactor.pycurrently uses a placeholder summarization strategy; it is not a full production summarizer yet.- Some historical dependencies may remain in
pyproject.toml; avoid documenting unused stacks as active runtime dependencies.
Follow this reasoning order:
- match current runtime code behavior
- preserve path safety and memory truth model
- keep context pipeline observable
- update docs in the same change