diff options
| author | Grail Finder <wohilas@gmail.com> | 2026-03-09 07:50:11 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2026-03-09 07:50:11 +0300 |
| commit | 94769225cfbcd4b0a30acab913915f45d6cb9f4b (patch) | |
| tree | e85ad71ed37da23db2ddc8289b44742354c057c7 /agent/pw_agent.go | |
| parent | 0e42a6f069ceea40485162c014c04cf718568cfe (diff) | |
Enha: agent client redo [WIP]
Diffstat (limited to 'agent/pw_agent.go')
| -rw-r--r-- | agent/pw_agent.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/agent/pw_agent.go b/agent/pw_agent.go new file mode 100644 index 0000000..8c1c2bf --- /dev/null +++ b/agent/pw_agent.go @@ -0,0 +1,40 @@ +package agent + +// PWAgent: is AgenterA type agent (enclosed with tool chaining) +// sysprompt explain tools and how to plan for execution +type PWAgent struct { + *AgentClient + sysprompt string +} + +// NewWebAgentB creates a WebAgentB that uses the given formatting function +func NewPWAgent(client *AgentClient, sysprompt string) *PWAgent { + return &PWAgent{AgentClient: client, sysprompt: sysprompt} +} + +func (a *PWAgent) ProcessTask(task string) []byte { + req, err := a.FormFirstMsg(a.sysprompt, task) + if err != nil { + a.Log().Error("PWAgent failed to process the request", "error", err) + return []byte("PWAgent failed to process the request; err: " + err.Error()) + } + toolCallLimit := 10 + for i := 0; i < toolCallLimit; i++ { + resp, err := a.LLMRequest(req) + if err != nil { + a.Log().Error("failed to process the request", "error", err) + return []byte("failed to process the request; err: " + err.Error()) + } + toolCall, hasToolCall := findToolCall(resp) + if !hasToolCall { + return resp + } + // check resp for tool calls + // make tool call + // add tool call resp to body + // send new request too lmm + tooResp := toolCall(resp) + req, err = a.FormMsg(toolResp) + } + return nil +} |
