Skip to content

How the agent works

Cosine is an AI software engineering agent that plans, writes, tests, and submits code by interacting with your existing repositories and tools.

When you give Cosine a task, it follows a loop of reasoning, tool use, and response:

  1. Read context — Cosine reads files, searches the codebase, and consults memory to understand the current state.
  2. Plan — For larger or ambiguous tasks, Cosine may pause to propose a plan before making changes.
  3. Act — Cosine edits files, runs terminal commands, uses MCP tools, or delegates to subagents.
  4. Validate — Cosine checks its work by running tests, reviewing diffs, or asking for your confirmation.
  5. Respond — Cosine reports back with a summary, asks clarifying questions, or asks for your approval before continuing.

Cosine has access to a set of tools depending on the surface and configuration:

  • File system — Read, write, search, and navigate your codebase
  • Terminal — Run shell commands in the task environment
  • LSP — Go-to-definition, find references, diagnostics
  • Browser — Navigate, screenshot, and extract data from web pages
  • MCP — Connect to external tools and APIs via Model Context Protocol servers
  • Git — Create commits, branches, and pull requests
  • Memory — Save and recall project conventions and user preferences

Cosine operates in multiple surfaces, each optimized for different workflows:

  • Cloud — Browser-based workspace for reviewing, planning, and managing tasks
  • CLI — Terminal user interface for local development and fast iteration
  • Desktop — Native app combining local file access with a visual workspace
  • VS Code — Extension for working inside your editor

Each surface shares the same agent core but exposes different controls and workflows. See Ways to use Cosine for a comparison.

Cosine reads configuration from multiple sources, in order of precedence:

  1. Command-line flags — Highest priority, per-session overrides
  2. Repository config — Project-specific settings in cosine.toml or .cosine.toml
  3. User config — Personal settings in ~/.cosine.toml
  4. Environment variables — System-level overrides
  5. Defaults — Built-in defaults (lowest priority)

This layered approach lets you set team-wide conventions in repo config, keep personal preferences in user config, and override everything on the command line when needed.