Skip to content

Conversation

@kujtimiihoxha
Copy link
Member

@kujtimiihoxha kujtimiihoxha commented Oct 28, 2025

This updates the fetch tool so it uses a subagent to search and find relevant information.

agentic_fetch.mp4

@kujtimiihoxha kujtimiihoxha requested a review from a team as a code owner October 28, 2025 14:25
@kujtimiihoxha kujtimiihoxha requested review from aymanbagabas and tauraamui and removed request for a team October 28, 2025 14:25
uses a subagent for researching and finding content
@kujtimiihoxha kujtimiihoxha changed the title feat: new fetch tool feat: agentic fetch tool Oct 29, 2025
Copy link
Member

@andreynering andreynering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few questions...

First, seeing that we can implement sub-agent easily is cool! That said, I am not so sure about the benefits in this case. How is this better than letting the main model do fetching in your opinion? I imagine letting the main agent process could be better due to having more context about the problem the user described. Also, would potentially use less tokens due to being more straighforward? (No need to ask to generate a prompt and then parse the result, etc. With a sub-agent we're kinda processing it twice. It felt slower to me as well, compared to before).

Second, wouldn't it be needed to keep the previous fetch tool? I suppose it would still be needed for some things, like fetching a JSON API, maybe from a server previously ran in brackground once #1328 is ready.

@kujtimiihoxha
Copy link
Member Author

First, seeing that we can implement sub-agent easily is cool! That said, I am not so sure about the benefits in this case. How is this better than letting the main model do fetching in your opinion? I imagine letting the main agent process could be better due to having more context about the problem the user described. Also, would potentially use less tokens due to being more straighforward? (No need to ask to generate a prompt and then parse the result, etc. With a sub-agent we're kinda processing it twice. It felt slower to me as well, compared to before).

The reason to use a subagent here is that we actually preserve tokens, in a lot of cases the information needed is in other pages and the agent needs to go and search for things... instead of polluting the context of the main agent with all the pages context we ask the subagent to find the thing that is actually needed and we preserve only that in the context (all the tool calls you see in the subagent are not send to the main agent) None of the HTML or unnecessary text in a webpage is sent to the main agent for sequential calls.

Second, wouldn't it be needed to keep the previous fetch tool? I suppose it would still be needed for some things, like fetching a JSON API, maybe from a server previously ran in brackground once #1328 is ready.

Yeah I think I will add back the concept of formats to fetch stuff... and add the simple fetch tool in addition to the agentic tool.

@kujtimiihoxha
Copy link
Member Author

@andreynering added the old fetch back and it is still smart enough to use the agent fetch with complex tasks

Complex task:
Screenshot 2025-10-30 at 15 41 41

Simple task:
Screenshot 2025-10-30 at 15 43 35

return fantasy.NewAgentTool(
tools.AgenticFetchToolName,
string(agenticFetchToolDescription),
func(ctx context.Context, params tools.AgenticFetchParams, call fantasy.ToolCall) (fantasy.ToolResponse, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of data validation logic in this lambda, it looks important to make sure we're getting these right and in order. Can we move this into a concrete/defined function and break it up into individual steps, either consolidate all of the validation to run at once as a method on a agent specific config type or break into individual functions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me know if this looks better now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants