gnosis / prediction-market-agent

GNU Lesser General Public License v3.0
28 stars 5 forks source link

Refactor microchain agent creation #258

Closed gabrielfior closed 4 months ago

gabrielfior commented 4 months ago

See comment in the bottom of this description for a more detailed explanation. tl;dr is to refactor build_agent and make engine creation, function registration and agent creation independent from one another.

Also relevant here is to refactor agent_functions, which depend on the agent itself. One idea that comes to mind is to expand the PromptHandler and have it manage the state of the prompt, so that the agent always reads from that before each run (instead of directly changing the agent's prompt inside a function).

          > however not sure how to handle the fact that this assignment ...

Not sure I understand. That could just stay where it is?

So before:

def build_agent(
    system_prompt: str,
    ....
):
    engine = Engine()
    agent = Agent(engine, ...)
    agent.system_prompt = system_prompt.format(engine_help=engine.help)

After:

engine = ...

def build_agent(
    system_prompt: str,
    engine: Engine,
    ....
):
    agent = Agent(engine)
    agent.system_prompt = system_prompt

But my point is that sequence of operations should be:

With maybe_append_function_definitions_into_prompt the hackyness is just moved somewhere else.

_Originally posted by @evangriffiths in https://github.com/gnosis/prediction-market-agent/pull/238#discussion_r1639831484_

evangriffiths commented 4 months ago

@gabrielfior we think this has been resolved by the later changes you made in https://github.com/gnosis/prediction-market-agent/pull/238. Do you agree, and we can close it?

gabrielfior commented 4 months ago

Yes, this has been solved. Closing.