Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

agent/executor: ignored options #1050

Open
treywelsh opened this issue Oct 18, 2024 · 0 comments
Open

agent/executor: ignored options #1050

treywelsh opened this issue Oct 18, 2024 · 0 comments

Comments

@treywelsh
Copy link
Contributor

treywelsh commented Oct 18, 2024

It's easy to make errors with the current options system, there's some cases where you're passing an option that is ignored.

For instance some objects like executors (Executor struct) and agents (OneShotZeroAgent, ConversationalAgent structs) share the same set of options but they don't use all of them.

There's probably the same problem in other parts of langchaingo but I only wanted to open a small discussion to know if this is relevant to others, or if we should consider that it's up to the developper to have a bit of "common sense" to know where it's relevant to use an option.

I was trying to build an agent :

	import (
        ...        
        "github.com/tmc/langchaingo/agents"
    )

    ...

	agent := agents.NewOneShotAgent(llm,
		[]tools.Tool{
			tool1,
            tool2,
		},
		agents.WithMaxIterations(5),
		//agents.WithParserErrorHandler(agents.NewParserErrorHandler(func(errStr string) string { ... })), // <- this options is useless here
	)
    executor := agents.NewExecutor(
		agent,
		agents.WithParserErrorHandler(agents.NewParserErrorHandler(func(errStr string) string { ... })), // <- it works here
	),

But agents.WithParserErrorHandler is ignored when passed to agents.NewOneShotAgent as an option.

To fix this we may introduce an executor package under agents:

	import (
        ...        
        "github.com/tmc/langchaingo/agents"
        agentExec "github.com/tmc/langchaingo/agents/executor"
    )

    ...

	agent := agents.NewOneShotAgent(llm,
		[]tools.Tool{
			tool1,
            tool2,
		},
		agents.WithMaxIterations(5),
		//agents.WithParserErrorHandler(agents.NewParserErrorHandler(func(errStr string) string { ... })), // <- this options is useless here
	)
    executor := agentExec.New(
		agent,
		agents.WithParserErrorHandler(agents.NewParserErrorHandler(func(errStr string) string { ... })), // <- it works here
	),

In addition this allow to shorten names a bit in a way that may be more intuitive i.e. pkgName.New
By the way names like agents.NewOneShotAgent a bit redundant.

I know this kind of changes would introduce breaking changes and it's probably not the most urgent change to add but if it matters I may open a PR for this ?

Seems related to: #1007 #862
I also saw that there's already some issues to reorg a bit the repository packages #369

@treywelsh treywelsh changed the title agent/executore: ignored options agent/executor: ignored options Oct 18, 2024
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

No branches or pull requests

1 participant