Skip to content

agent: add Prompt method and Activity tracking#2864

Open
Copilot wants to merge 3 commits intomasterfrom
copilot/add-agents-managing-services
Open

agent: add Prompt method and Activity tracking#2864
Copilot wants to merge 3 commits intomasterfrom
copilot/add-agents-managing-services

Conversation

Copy link
Contributor

Copilot AI commented Feb 22, 2026

Agents needed a way to receive on-demand prompts at runtime and a general mechanism to observe what they are doing.

Changes

Agent interface additions

  • Prompt(text string) <-chan *model.Response — non-blocking; spawns a goroutine that runs the prompt through the model (including tool execution), then delivers the response on a buffered channel and closes it. Channel is closed with no value if no model is configured.
  • Activity() []Activity — returns a safe snapshot copy of the agent's activity log, capped at 256 entries.

Activity tracking

  • ActivityType string constants: evaluate, prompt, tool, response, error
  • Activity struct: Time, Type, Prompt, Tool, Result, Err
  • Internal record() helper — thread-safe, drops oldest entries beyond cap
  • evaluate() now records each cycle's evaluate/tool/response/error events
  • Tool call results are classified as ActivityError vs ActivityTool via JSON inspection of the content string

Usage

a := micro.NewAgent(
    agent.WithName("greeter-manager"),
    agent.WithModel(m),
    agent.WithDirective("Ensure greeter is healthy"),
)
go a.Run()

// Queue a prompt from any goroutine; non-blocking
ch := a.Prompt("how many nodes does greeter have?")
resp := <-ch // blocks only the caller, not the agent loop
fmt.Println(resp.Reply)

// Inspect recent activity
for _, act := range a.Activity() {
    fmt.Printf("[%s] %s %s\n", act.Time.Format(time.RFC3339), act.Type, act.Result)
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add agent management for service lifecycle Add agent package: AI-driven service lifecycle management Feb 22, 2026
Copilot AI requested a review from asim February 22, 2026 21:23
Copilot AI changed the title Add agent package: AI-driven service lifecycle management agent: add Prompt method and Activity tracking Feb 22, 2026
@asim asim marked this pull request as ready for review February 23, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants