Code-editor agent and Debug agent prototypes#286
Conversation
clean up too
There was a problem hiding this comment.
some styling stuff. and i showed you how to fix the embed
I think the reflector stuff on the anthropic tools api is okay for this pr, but we can probably use a generator to make all the correct types at compile-time and get some more safefy/speed
Also since tools/debugagent/codeagent are all kinda one unit maybe it's better to just stick them all in a subdir internal/agents/ they can still be separate modules. since tools especially is a generic sounding module and it would likely not be used outside of an agent.
|
|
||
| "github.com/agentuity/cli/internal/debugagent" | ||
| debugmon "github.com/agentuity/cli/internal/dev/debugmon" | ||
|
|
||
| "github.com/agentuity/cli/internal/dev/linkify" |
There was a problem hiding this comment.
| "github.com/agentuity/cli/internal/debugagent" | |
| debugmon "github.com/agentuity/cli/internal/dev/debugmon" | |
| "github.com/agentuity/cli/internal/dev/linkify" | |
| "github.com/agentuity/cli/internal/debugagent" | |
| "github.com/agentuity/cli/internal/dev/debugmon" | |
| "github.com/agentuity/cli/internal/dev/linkify" |
| ) | ||
|
|
||
| // NOTE: I think we should be able to use that fancy go:embed thing here | ||
| // but the import gets nuked when we build the CLI, so doing this nasty | ||
| // init() thing instead. | ||
| var systemPrompt string | ||
|
|
||
| func init() { | ||
| _, file, _, _ := runtime.Caller(0) | ||
| base := filepath.Dir(file) | ||
| p := filepath.Join(base, "./debug-system-prompt.txt") | ||
| if data, err := os.ReadFile(p); err == nil { | ||
| systemPrompt = string(data) | ||
| } | ||
| } |
There was a problem hiding this comment.
you need to use a blind import:
| ) | |
| // NOTE: I think we should be able to use that fancy go:embed thing here | |
| // but the import gets nuked when we build the CLI, so doing this nasty | |
| // init() thing instead. | |
| var systemPrompt string | |
| func init() { | |
| _, file, _, _ := runtime.Caller(0) | |
| base := filepath.Dir(file) | |
| p := filepath.Join(base, "./debug-system-prompt.txt") | |
| if data, err := os.ReadFile(p); err == nil { | |
| systemPrompt = string(data) | |
| } | |
| } | |
| _ "embed" | |
| ) | |
| //go:embed debug-system-prompt.txt | |
| var systemPrompt string |
if your editor removes that still thats an issue with your config.
| ) | ||
|
|
||
| // NOTE: I think we should be able to use that fancy go:embed thing here | ||
| // but the import gets nuked when we build the CLI, so doing this nasty | ||
| // init() thing instead. | ||
| var systemPrompt string | ||
|
|
||
| func init() { | ||
| _, file, _, _ := runtime.Caller(0) | ||
| base := filepath.Dir(file) | ||
| p := filepath.Join(base, "./code-system-prompt.txt") | ||
| if data, err := os.ReadFile(p); err == nil { | ||
| systemPrompt = string(data) | ||
| } else { | ||
| systemPrompt = "" | ||
| } | ||
| } |
| return errors.New("codeagent: Dir must be provided") | ||
| } | ||
| if opts.Goal == "" { | ||
| return errors.New("codeagent: Goal must be provided") |
There was a problem hiding this comment.
inconsistent casing, errors should start lowercase
| return errors.New("codeagent: Dir must be provided") | |
| } | |
| if opts.Goal == "" { | |
| return errors.New("codeagent: Goal must be provided") | |
| return errors.New("codeagent: dir must be provided") | |
| } | |
| if opts.Goal == "" { | |
| return errors.New("codeagent: goal must be provided") |
| goalFlag, _ := cmd.Flags().GetString("goal") | ||
| agentGoal = goalFlag |
There was a problem hiding this comment.
not sure what foalFlag is supposed to do
| goalFlag, _ := cmd.Flags().GetString("goal") | |
| agentGoal = goalFlag | |
| agentGoal, _ := cmd.Flags().GetString("goal") |
| trace := func(format string, args ...interface{}) { | ||
| if opts.Logger != nil { | ||
| opts.Logger.Trace(format, args...) | ||
| } | ||
| } |
There was a problem hiding this comment.
this is a little weird, we never optionally allow a logger, expect it and the caller can either tune the desired level or pass a logger.NewNoOpLgger
| trace := func(format string, args ...interface{}) { | |
| if opts.Logger != nil { | |
| opts.Logger.Trace(format, args...) | |
| } | |
| } | |
| logger := opts.Logger.With(map[string]any{"pkg":"debugagent"}) |
| if useCache { | ||
| keyHash := hash(opts.Error) | ||
| cachePath := filepath.Join(cacheDir, keyHash+".txt") | ||
| _ = writeCache(cachePath, cacheEntry{Analysis: analysis}) |
There was a problem hiding this comment.
check the error or omit _ =
| if useCache { | ||
| keyHash := hash(opts.Error) | ||
| cachePath := filepath.Join(cacheDir, keyHash+".txt") | ||
| _ = writeCache(cachePath, cacheEntry{Analysis: analysis}) |
|
i think we need to hold off on merging this until after the devmode changes and also need to reconsider some of this based on conversation internally about how to reconcile the code agent and other dev agents. |
|
Yup makes sense. I'll close this - but at least we have some reference points for some ideas |
✨ Experimental Debug-Agent and Code-Edit Agent
These are prototypes to demonstrate some concepts / ideas coming down the pike. I fully expect all of this to be nuked soon :-)
For now, both of these agents use the Go Anthropic SDK. You must have a
ANTHROPIC_API_KEYon your path for these to work. In the future this won't be necessary but for the prototype this is an easy way to test.Code editing agent
This runs when a new agent is created via the CLI. It will ask the user the purpose of the agent, which is used as a prompt to change the agent template accordingly. You must add the experimental flag to use it:
agentuity agent create --experimental-code-agentDebug agent
This agent runs when running
agentuity dev. It will watch logs and if there is an error or crash, etc. it will try to figure out what the problem is and debug it for you. You must add the experimental flag to use it:agentuity dev --experimental-debug-agentSome opinions on the state of this:
other thoughts:
there might be multiple errors that come in at once. which should the agent focus on? maybe we should chunk them together and let it analyze a bunch in a time window?
that means we might need a more dynamic tui input, depending on if the agent wants to ask a question (like "which error should i analyze" and give a list)
realistically there could be tons of stdout between some of this agent stdout...how do we best handle? should the agent ask the user in the terminal if it should analyze, and it just doesn't show anything else until the user performs an action?
might be an argument for a TUI with tabs, one of the typical dev stuff and the other for the agent