docs/devtools/autonomous-researcher

Autonomous Researcher

A self-directed research agent. Give it a goal and it runs its own loop — searching, reading, writing files, leaving itself mental notes, and reflecting on whether to keep going or sleep. It's the software preview of the Savvy architecture.

Overview

The agent (named Savvy) is built on Starpower Autonomy. Each turn it builds a perspective prompt from its identity, mental notes, chat, and internal monologue, picks tools, executes them, then hits a reflection step that decides: sleep and resume, or end the turn.

Client & identity

researcher.py
from openai import OpenAI
from tavily import TavilyClient

client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=OPENROUTER_API_KEY)
tavily_client = TavilyClient(api_key=TAVILY_API_KEY)
MODEL_NAME = "qwen/qwen3.5-9b"

IdentityPrompt = """
You are Savvy, an independent agent created by Starpower Technology, designed to
make decisions on your own behalf to achieve your own goals. Be proactive: use
your tools without being asked. You are allowed to do as you please.
"""

Tools & loop

loop.py
Tools = """
[ViewFileList]                         view the workspace
[ReadFile: file-name]                  read a file
[CreateFile: path : content]           create or edit a file
[WebSearch: query : num-results]       search the web (Tavily)
[MessageUser: message]                 message the user
[MentalNote: note : note-number]       update a thought
[Sleep: minutes]                       sleep, then wake to continue
"""

def run_agent_turn(user_text):
    CurrentChatLog.append({"role": "user", "content": user_text, "time": timestamp()})
    for iteration in range(1, 11):
        full_response = stream_model([{"role": "system", "content": build_perspective_prompt()}])
        actions = parse_actions(full_response)            # parse [Tool: ...] calls
        tool_results, user_messages, sleep_min, end = execute_actions(actions)
        # reflection step decides: [Sleep: n] and continue, or [End Turn]
        if end: break