-
Notifications
You must be signed in to change notification settings - Fork 889
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
Fix Agents to support code and rag simultaneously #908
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ | |
from llama_stack.providers.utils.kvstore import KVStore | ||
from llama_stack.providers.utils.memory.vector_store import concat_interleaved_content | ||
from llama_stack.providers.utils.telemetry import tracing | ||
|
||
from .persistence import AgentPersistence | ||
from .safety import SafetyException, ShieldRunnerMixin | ||
|
||
|
@@ -476,9 +477,12 @@ async def _run( | |
) | ||
span.set_attribute("output", retrieved_context) | ||
span.set_attribute("tool_name", MEMORY_QUERY_TOOL) | ||
if retrieved_context: | ||
last_message = input_messages[-1] | ||
last_message.context = retrieved_context | ||
|
||
# append retrieved_context to the last user message | ||
for message in input_messages[::-1]: | ||
if isinstance(message, UserMessage): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What other message type could this be if it's triggering RAG? Separately curious why for RAG results we use .context but for other tool execs we do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ehhuang I think @hardikjshah did this so you could identify which message you added context to and then in the next turn get rid of it. we needed to keep only one context around as the turns proceeded. I really think we should nuke that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That was the original bug , where if both code and rag are enabled, we end up with a ToolResponseMessage coming from the code_interpreter side (check out And it was erroring since I agree that we should find a better solution to |
||
message.context = retrieved_context | ||
break | ||
|
||
output_attachments = [] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there another place where we set the context for RAG?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah how does RAG even work if you don't do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, all tests were passing for RAG but then i realized there was nothing getting added to the context.
I tested this change and now can see RAG work properly.