Bounded Task Context Agent
We explain a bounded-context coding agent architecture with an external Task Context, negative knowledge, and a state machine. We show how it aligns with Domain-Isolated AI Architecture and why we design TaoCoder IDE for production AI coding this way.
Bounded Task Context Agent: How to Build Coding Agents Without Context Degradation and Unpredictable Cost
The coding-agents market is going through a familiar phase: demos look impressive, but the moment you try to use an “agent inside an IDE” on a long task, in a real repository, and with real accountability, the system starts to degrade.
The degradation pattern is almost always the same:
- context grows, and the cost of each step increases;
- the agent loses focus and starts repeating itself;
- “magic memory” appears, which either leaks between tasks or turns into junk;
- giving the agent more tools makes it less controllable and more risky.
The main thesis of this article is:
to be a production tool, a coding agent needs bounded context at every step, an external managed task state, and a strict execution model instead of an “endless chat with memory”.
We call this architecture the Bounded Task Context Agent. It directly aligns with our broader framework, Domain-Isolated AI Architecture: instead of “one agent for everything”, we build isolated contours, and inside each contour we run predictable, verifiable cycles with bounded context.
Important: this is not theory for us. We built TaoCoder IDE around these principles as a workstation for production AI coding. We implemented it on top of a mature open-source core, adding our own agent runtime, control plane, and infrastructure on top. In this article we show exactly what we got.
Why Typical IDE Agents Degrade
1) Linear “memory” turns an agent into an expensive chat
A typical agent today follows an append-only pattern:
- read files and logs;
- push everything into the prompt context;
- on the next step, drag even more text into the model;
- once the context overflows, run compaction/summarization;
- lose details and repeat already explored branches.
The result is predictable: every subsequent action becomes more expensive and less accurate, because the model is forced to “digest history” instead of solving the next concrete step.
2) “More tools” without boundaries = a wider execution surface
When an agent gets access to a browser, shell, files, APIs, and integrations, it feels like a power-up. In real operations it quickly becomes a problem:
- permissions are harder to constrain;
- inputs/outputs are harder to validate;
- audits get more expensive;
- the cost of mistakes goes up.
That is why the baseline template “one universal agent that we give everything” does not work.
The Bounded Task Context Agent Architecture
Principle 1. An LLM is a decision processor, not a memory store
The LLM should make decisions, but “task memory” should not be an append-only prompt log. Memory must be externalized into a separate artifact.
Principle 2. Task Context as an external kernel of task state
Instead of keeping history and tool logs inside the model context, we introduce an external Task Context: a compact, managed state for the task.
On every step, the agent receives:
- the Task Context (minimal sufficient state);
- the goal of the current step;
- a small recent window of actions (without long logs and dumps).
Task Context stores not “the whole history”, but structured links:
- relevant code (path + line range + why it matters);
- decisions (what we chose and why);
- negative knowledge (what was tested and does not work);
- a short execution log (links to artifacts, not copy-pasted blocks).
Principle 3. Negative knowledge is mandatory
Most of the cost in a long task is not in “thinking”, but in repeatedly walking into dead ends.
That is why negative knowledge is a first-class entity:
- “we tested this branch, it does not fit”;
- “this file is legacy and not used in the current flow”;
- “this approach breaks the contract, do not repeat”.
This turns the agent from a “chatty explorer” into a system that learns not to repeat its own mistakes over a long horizon.
Principle 4. A state machine instead of “magic”
To make behavior predictable, agent work is modeled as a finite set of stages:
- task clarification;
- data collection;
- development;
- audit/verification;
- report/handoff;
- a separate cycle for rework.
Each stage has:
- allowed tools;
- exit criteria;
- verification patterns.
This is a simple idea, but it changes everything: the agent stops being a “universal talker” and becomes a controlled production loop.
How This Is Implemented in TaoCoder IDE
We built TaoCoder IDE as a VS Code extension, implementing all four principles in code. Here is what we got:
Task Context on disk
Every task has its own Task Context — a JSON file on disk that contains:
- spec — what needs to be done, acceptance criteria, constraints;
- implementation_plan — step checklist with statuses (TODO / IN_PROGRESS / DONE);
- relevant_code — references to relevant code with explanations;
- decisions — decisions made with justification;
- negative_knowledge — what was tested and does not work;
- changes — all code changes with diffs;
- notes — observations, hypotheses, notes.
Task Context is a bounded prompt: only the current state goes in, not the entire dialog history. The model receives a structured task state, not a growing log.
Stage pipeline with tool gating
TaoCoder works through stages. Each stage has its own set of available tools:
- Architect — design, document creation, requirements analysis;
- Developer — development, audit, report;
- Ops — deployment, monitoring, infrastructure;
- Debug — E2E testing, debugging;
- Free — quick edits without stage gating.
During the data collection stage, write tools are locked: the agent cannot accidentally modify code while studying the project. During the development stage, deployment tools are locked. This makes behavior predictable and safe.
Update-cycle: two mechanisms for memory updates
We implemented two mechanisms for transferring information from dialog to long-term memory:
-
Conscious recording — the agent explicitly calls tools (
taocoder_add_relevant_code_ref,taocoder_add_note, etc.) to record findings, decisions, hypotheses. -
Automatic update-cycle — the system periodically analyzes the accumulated dialog and extracts additional facts, updating Task Context without explicit commands from the agent.
This solves the “forgotten findings” problem: if the agent found something important in the middle of a task, it won’t be lost.
Parallel tasks: multiple tasks simultaneously
TaoCoder supports parallel task execution in a single VS Code window. Each task runs independently:
- its own Task Context;
- its own terminals;
- its own metrics (tokens, cost, duration);
- its own stage pipeline.
You can run one task on a fast flash model (e.g., DeepSeek 4 Flash) for simple edits, and in parallel — on a powerful model (DeepSeek 4 Pro) for complex refactoring. Background tasks continue working but pause at approval points (file edits, command execution).
Custom role modes
In addition to built-in modes (Architect, Developer, Ops, Debug, Free), you can create your own role modes with unique stages and tools. For example:
- Log Analyst — log analysis, anomaly detection, report generation;
- Content Manager — documentation updates, blog posts, translations;
- Code Reviewer — code review focused on security and performance.
Each custom mode has its own stage pipeline, its own tools, and its own exit criteria.
Task Scheduler: cron-based scheduling
TaoCoder supports automatic task execution on a schedule. Agents work on cron:
- log checks every hour;
- deployment every evening;
- security audit every week;
- documentation updates every month.
The scheduler is integrated with Task Context: each scheduled task creates its own context, runs through the stage pipeline, and records results.
Command Safety: deterministic command classification
Every command the agent wants to execute goes through deterministic classification:
- safe — safe commands (ls, cat, grep);
- dangerous — dangerous commands (rm -rf, git push —force);
- requires_approval — require explicit user confirmation;
- unknown — unknown commands, require manual review.
Black and white lists, custom rules are supported. The agent won’t execute rm -rf without explicit permission. This makes execution predictable and safe.
JEV Decision Model: probabilistic decision-making
JEV (Justification-Evidence-Verification) is a probabilistic decision-making model used for:
- stage transition validation — before moving to the next stage, the system checks whether exit criteria are met;
- command safety verification — before executing a command, the system assesses risk;
- on-demand agent decision validation — the user can request justification for any agent decision.
JEV returns a success probability based on justification, evidence, and verification. This makes agent behavior explainable and verifiable.
Secrets Management: zero-trust architecture
API keys and secrets never reach the agent context. A zero-trust architecture is implemented:
- automatic secret extraction from code;
- storage in VS Code SecretStorage (IDE-level encryption);
- injection only at execution time (via environment variables);
- secrets are not visible in the prompt, Task Context, or logs.
This solves the problem of API key leakage through the model context.
Handoff: controlled context transfer between tasks
TaoCoder supports handoff — context transfer between tasks. For example:
- Debug finds a bug → creates a handoff for Developer;
- Developer fixes the bug → creates a handoff for Ops;
- Ops deploys → records the result in Task Context.
Handoff transfers relevant code, decisions, negative knowledge. Duplicates are filtered out automatically. This makes multi-agent work coordinated.
Task Context Cockpit: UI for state management
TaoCoder provides a UI panel (Task Context Cockpit) for managing task state:
- editing spec, plan, acceptance criteria;
- viewing code references, changes, notes;
- snapshots and rollback to any execution point;
- stage pipeline visualization and current state.
This makes agent work transparent and manageable.
Metrics: full cost transparency
TaoCoder records metrics in real-time:
- task duration;
- API call count;
- token usage (input/output);
- cost (breakdown by models and providers);
- breakdown by stages and modes.
You see how much each development phase costs. This makes cost predictable and explainable.
Architectural optimization for flash models (bounded prompt, structured Task Context, stage-based tool gating) delivers 10–30× cheaper results than classic AI agents on frontier models.
How This Relates to Domain-Isolated AI Architecture
Domain-Isolated AI Architecture answers “what a production AI system should look like at the macro level”, while Bounded Task Context Agent answers “how a long task should run inside an isolated contour”.
The combined model looks like this:
- isolation by domains and projects defines boundaries for memory, permissions, and accountability;
- Task Context becomes a local “task state board” inside a specific domain/project contour;
- task-oriented sub-agents handle narrow roles (analysis, generation, validation, audit) instead of “everything”;
- a control layer constrains actions and turns them into contract-based operations;
- a validation layer checks inputs/outputs and blocks invalid results from moving forward;
- a bounded main context stabilizes cost and quality at every step.
If you compress it into one sentence:
Domain Isolation makes the system safe and governable by boundaries, while Bounded Task Context makes each long task predictable in cost and quality.
Why We Built TaoCoder IDE This Way
At the market level, “vibe coding” is popular: let the agent write and see what happens. At the business level, you quickly hit the real requirements:
- you need an outcome by a deadline, not infinite generation;
- you need risk control, not broad access to dangerous actions;
- you need a cost model you can explain and repeat;
- you need an audit trail of what was done and why.
That is why TaoCoder IDE is built around a production template:
- bounded context at every step;
- external Task Context as task state;
- separating intelligence from execution via contracts;
- control and validation as dedicated engineering layers;
- isolation by projects and domains.
Technically, we implemented TaoCoder IDE on top of a ready-made open-source core (VS Code), because there is no reason to reinvent what the community already solved well: UI, editing, language integrations, and baseline infrastructure.
Our focus is not “yet another editor”, but a production architecture:
- an agent runtime with bounded context;
- Task Context as managed task memory;
- a controlled tool-and-operations layer (Command Safety, JEV);
- zero-trust Secrets Management;
- parallel tasks and handoff between them;
- custom role modes and scheduler;
- Task Context Cockpit for state management;
- metrics and observability;
- result validation via check_all.sh.
Conclusion
A strong coding agent is not “a bigger model” and not “a longer chat”.
A production agent inside an IDE is an architecture where:
- task memory is externalized and managed;
- context at each step is bounded and minimal sufficient;
- dead ends are captured as negative knowledge and not repeated;
- execution runs through contracts, control, and validation;
- domains and projects are isolated instead of mixed in one universal memory.
We call this combination Domain-Isolated AI Architecture + Bounded Task Context Agent and built TaoCoder IDE around it as a production tool for companies that need not demo-magic, but predictable AI delivery with controlled risk.
TaoCoder IDE is already working: parallel tasks, custom modes, scheduler, Command Safety, JEV Decision Model, Secrets Management, Handoff, Task Context Cockpit, metrics — all of this is implemented and available in the VS Code Marketplace. Try it and see for yourself.
Need a similar engineering loop?
Share the task, and we will suggest an architecture, control layer, and rollout path.
Discuss a project