Build Your Own Coding Agent

Create an AI coding assistant that can read your codebase, make edits, run tests, and iterate until the code works — deployed as an OpenAI-compatible API endpoint.

Deploy in one click: AI Coding Agent Template

What You'll Build

An AI agent that:

  1. Receives a coding task via HTTP API
  2. Reads relevant source files
  3. Makes targeted code edits (find-and-replace)
  4. Runs tests or builds to verify
  5. Iterates if tests fail
  6. Streams the final response back

Prerequisites

  • Tensorify CLI installed and running (tensorify runner start)
  • An OpenAI or Anthropic API key
  • A Tavily API key (for web search, optional)
  • A project directory on your machine

Architecture

POST /coding-agent  →  API Trigger  →  AI Agent  →  Return (SSE stream)
                                          ├── File Ops (read/write/replace)
                                          ├── Shell (run tests, git)
                                          ├── System Info (check processes)
                                          └── Web Search (lookup docs)
                                          └── Window Memory (conversation)

Step-by-Step Setup

Create from Template

Go to Templates → "AI Coding Agent" → Create. This gives you the full workflow pre-wired.

Configure Secrets

In workspace Settings → Env Vars, add:

  • OPENAI_API_KEY — your OpenAI key (or ANTHROPIC_API_KEY if using Claude)
  • SEARCH_API_KEY — Tavily key for web search (optional)

Set the Working Directory

In the Shell node settings, set working_directory to your project path:

/home/you/projects/my-app

This is where the agent will run commands from.

Configure Agent Permissions

In the File Ops node, set allowed_operations to control what the agent can do:

  • Safe: ["read", "list", "replace"] — can read and make targeted edits
  • Full: all operations — can create/delete files too

Deploy in CLI Mode

Select "Self-Hosted" in the execution target, then click Deploy. The workflow runs on your machine with full filesystem access.

Test with curl

curl -N -X POST https://triggers.tensorify.io/{team}/{path} \
  -H "Content-Type: application/json" \
  -d '{"message": "Fix the failing test in src/auth.test.ts"}'

The -N flag enables streaming — you'll see the agent's reasoning in real-time.

Using with OpenAI SDK

The API Trigger with protocol: "openai-chat" makes your agent compatible with any OpenAI client:

from openai import OpenAI

client = OpenAI(
    base_url="https://triggers.tensorify.io/{team}/{path}",
    api_key="not-needed"  # auth handled by Tensorify
)

response = client.chat.completions.create(
    model="coding-agent",
    messages=[{"role": "user", "content": "Add error handling to the login function"}],
    stream=True
)

for chunk in response:
    print(chunk.choices[0].delta.content or "", end="")

How the Agent Works

The AI Agent uses a ReAct loop (Reason → Act → Observe):

  1. Reason: "I need to read the test file to understand the failure"
  2. Act: Calls file_ops({ operation: "read", path: "src/auth.test.ts" })
  3. Observe: Sees the file contents, identifies the bug
  4. Reason: "The test expects a different return type. I'll fix the implementation."
  5. Act: Calls file_ops({ operation: "replace", path: "src/auth.ts", find: "...", replace_with: "..." })
  6. Act: Calls shell({ operation: "exec", command: "npm test src/auth.test.ts" })
  7. Observe: Tests pass!
  8. Respond: "Fixed the auth function — the test was expecting an object but got a string..."

Tips

  • Model choice: Use GPT-4o or Claude Sonnet for complex coding tasks; GPT-4o-mini for simple fixes
  • Max iterations: Set to 15+ for complex multi-file changes
  • Temperature: Keep low (0.1–0.3) for deterministic code edits
  • System prompt: Be specific about your codebase (language, framework, test runner)
  • find-and-replace: More reliable than full file rewrites for targeted edits
  • Conversation memory: Persists across requests, so the agent remembers your codebase context

Next Steps

  • Connect to Slack or Telegram for chat-based coding assistance
  • Add GitHub plugin to automatically create PRs with fixes
  • Set up a dedicated project directory for the agent to work in
On this page