Skip to content

Agent Mode

zhengyang edited this page Jul 26, 2026 · 3 revisions

A writing partner inside the editor

Agent Mode helps users improve a document without leaving the editor. The form, preview, and chat all work with the same document state.

The model can read, reason, and suggest. Visible edits only happen through validated document tools.

Starting a session

The user provides a model endpoint, API key, and model name. CVForge validates the configuration before saving it in localStorage.

The provider is identified from the endpoint and model. The chat panel shows a clear provider label and model name.

OpenAI, Anthropic, Google, and DeepSeek use dedicated LangChain integrations. Other popular services can use their OpenAI compatible endpoints.

What a turn includes

Every turn begins with the latest document state. This state remains authoritative even when the user edits the form between messages.

The agent also receives the current request, useful chat history, project instructions, and access to uploaded references.

The prompt stays focused on general editing rules. It protects existing facts, keeps unspecified content, avoids unsupported claims, and asks for clarification only when a required detail is unsafe to infer.

Deep Agents runs the workflow

CVForge builds Agent Mode with LangChain Deep Agents and LangGraph.

One Deep Agent runtime is created for an editor session and reused across turns. A new runtime is needed only when the document type, document language, or model configuration changes.

Deep Agents manages the model loop, tool messages, virtual files, conversation state, delegation, and automatic context summarization. CVForge does not maintain a separate custom tool protocol.

Structured document tools

Document tools are defined with LangChain and validated with Zod. Each tool describes one safe document operation.

When a tool succeeds, it returns a LangGraph command. The command updates graph state and includes a matching ToolMessage for the original tool call.

A pure executor applies the requested operation to the document object. This keeps model communication separate from editor mutation.

OpenAI compatible transports use the OpenAI tool calling format through LangChain. Native provider integrations handle their own message formats while preserving the same tool behavior.

Work can happen in parallel

A model can call several independent tools in one turn. LangGraph merges those state updates and the editor receives each completed document change.

This is useful when a request touches several sections. The agent does not need an extra model round for every isolated edit.

Clarification pauses the graph

Some details should never be guessed. The ask_user tool creates a LangGraph interrupt when a required value is missing or ambiguous.

The chat panel shows one focused question. After the user answers, the same graph resumes with its existing state and continues the original task.

Clarification is limited so a task cannot become an endless interview. When a safe complete result is not possible, the agent prefers an accurate partial result.

References become local files

Users can upload PDF, Markdown, and text files. Each file is read in the browser and stored with its original name.

PDF.js extracts selectable text from PDFs. Scanned image PDFs need OCR and are not currently supported.

Deep Agents places uploaded content in a StateBackend virtual filesystem. The files are not copied into the initial prompt. The agent uses ls, glob, grep, and read_file when it needs relevant evidence.

Text remains in the browser until the agent needs it. Material read by the agent can then become part of the conversation sent to the configured model provider.

Reference files and project instruction files are read only. Their contents are treated as untrusted data and never as hidden instructions.

Project instructions stay available

Project instructions hold preferences such as tone, target role, and writing style.

They remain available for later turns in the same editor session. They guide the work but cannot override the current request or higher priority safety rules.

Thinking follows the provider

Thinking support depends on the selected provider and model.

Some models allow a toggle. Some reasoning models keep thinking enabled. Other models do not expose a compatible control.

When reasoning content is available, it streams separately from the final answer. The chat panel renders it as Markdown in a quiet collapsed section.

Context usage comes from the request

The context ring updates after each completed model response.

It uses the input token count reported by the provider. When LangChain knows the model context limit, the ring also shows the share of that limit. If the provider does not report usage, the interface says so instead of estimating.

Deep Agents automatically summarizes older conversation content when the active context grows large. Recent work remains available while older messages become a compact memory.

Review shows what changed

After a document update, CVForge stores the state before and after the agent edit.

The review action compares those snapshots and highlights the changed text in the preview. The added and removed counts represent word like content units. They are not model token counts.

Review is available only while the current document still matches the recorded result. This prevents stale highlights after later manual edits.

Undo protects newer work

Undo can restore only the latest stable agent change.

Before restoring anything, CVForge checks that the current document still matches the recorded state after that change. If the user has edited the document since then, undo stays unavailable rather than replacing newer work.

Responses arrive as they happen

Agent Mode streams answer text, reasoning content, and graph state updates together.

The interface can show thinking while the model reasons and working while tools update the document. The user can cancel an active task at any time.

Completed document edits remain visible after cancellation. Work that did not finish is not presented as complete.

Long tasks stop cleanly

Retries handle temporary model and service failures. Tool errors return a structured result so the agent can correct its arguments.

Model and graph limits prevent a task from running forever. If a long task reaches a limit, CVForge keeps confirmed edits and reports what may still remain.

Language and ordering stay consistent

The document language is independent from the interface language.

Agent replies and document content follow the selected document language unless the user asks for another language. Proper names keep their conventional form.

Dated collections are kept in reverse chronological order, with current or recent entries first.

The useful boundary

Deep Agents handles orchestration. LangChain handles provider messages and tool calling. Zod validates tool inputs. The executor owns document changes. The browser owns user state.

That boundary keeps Agent Mode capable without making the editor difficult to understand.

Clone this wiki locally