feat: Add context_id history to agent and chat#10319
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe PR adds a new "context_id" input field across agent, chat input, and chat output components. This context_id is threaded through the messaging system and memory retrieval flow to enable context-scoped memory operations. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Consistent, homogeneous pattern applied across three files: adding the same MessageTextInput field type and threading it through existing function calls. Changes are mechanical and follow a repetitive structure with minimal logic density. Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 error, 3 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Component index has been automatically updated due to changes in New Index: |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/lfx/src/lfx/components/agents/agent.py (1)
88-94: Consider centralizing the context_id input definition.The context_id input field is defined identically in three components (ChatInput, ChatOutput, AgentComponent). If this pattern is common in the codebase, consider creating a shared constant or factory function to reduce duplication.
Example approach (to be applied in a shared module):
# In a shared module (e.g., lfx/components/common/inputs.py) CONTEXT_ID_INPUT = MessageTextInput( name="context_id", display_name="Context ID", info="The context ID of the chat. Adds an extra layer to the local memory.", value="", advanced=True, )Then import and use it in each component:
from lfx.components.common.inputs import CONTEXT_ID_INPUT inputs = [ ..., CONTEXT_ID_INPUT, ..., ]
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/lfx/src/lfx/components/agents/agent.py(3 hunks)src/lfx/src/lfx/components/input_output/chat.py(2 hunks)src/lfx/src/lfx/components/input_output/chat_output.py(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/lfx/src/lfx/components/input_output/chat_output.py (1)
src/lfx/src/lfx/inputs/inputs.py (1)
MessageTextInput(206-257)
src/lfx/src/lfx/components/agents/agent.py (1)
src/lfx/src/lfx/inputs/inputs.py (2)
MessageTextInput(206-257)MultilineInput(260-270)
src/lfx/src/lfx/components/input_output/chat.py (1)
src/lfx/src/lfx/inputs/inputs.py (1)
MessageTextInput(206-257)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Update Starter Projects
- GitHub Check: update-index
🔇 Additional comments (6)
src/lfx/src/lfx/components/input_output/chat.py (2)
63-69: LGTM!The context_id input field is well-configured with appropriate metadata and follows the same pattern as session_id above it.
97-97: No action required - Message.create() properly accepts context_id parameter.Verification confirms the Message.create() method is a @classmethod that accepts
**kwargs, and the Message class definescontext_idas a valid field. The context_id parameter passed in chat.py line 97 will be correctly accepted and processed.src/lfx/src/lfx/components/agents/agent.py (2)
24-24: LGTM!The MessageTextInput import is correctly added to support the new context_id field.
418-418: No action needed—context_id parameter is correctly supported.Verification confirms that
MemoryComponent.set()accepts thecontext_idparameter. TheComponentbase class definesset(**kwargs)at line 395, which accepts arbitrary keyword arguments and processes them through_process_connection_or_parameters(). SinceMemoryComponentdefinescontext_idas an explicit input parameter, passing it via.set(context_id=self.context_id)at line 418 is correct and will not cause runtime errors.src/lfx/src/lfx/components/input_output/chat_output.py (2)
66-72: LGTM!The context_id input field is consistently defined with the same configuration as in the other components.
131-131: ****The Message class already has a
context_idattribute defined insrc/lfx/src/lfx/schema/message.pyascontext_id: str | UUID | None = Field(default=""). The assignment at line 131 is valid and will not cause AttributeError at runtime.Likely an incorrect or invalid review comment.
|
Eric, it worked as expected! One observation is that, as shown in the video, when retrieving conversations from B (or any other sequential agent), it's not possible to retrieve the agent's input (I believe the input is controlled by Chat Input and it is only possible to add one to the flow.) In the current format, I've already unlocked many cases, and it already avoids the main problem of mixing up agent memories. But if we could have the input in B's memory, just like we have in A, it would be perfect! In A, we see: In B, we see: Gravacao.de.Tela.2025-10-17.180331.mp4 |
Empreiteiro
left a comment
There was a problem hiding this comment.
LGTM! The observations made in the other comment will be considered in the future!
|
* feat: Add context_id history to agent and chat * chore: update component index --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* feat: Add context_id history to agent and chat * chore: update component index --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>



This pull request introduces support for a new
context_idfield across several chat-related components in the codebase, allowing for an additional layer of context in chat sessions and memory handling. The changes ensure thatcontext_idcan be input, stored, and utilized throughout the chat workflow, improving the granularity of context management.Context ID support in chat components:
MessageTextInputforcontext_idto the input configuration ofAgentComponent,ChatInput, andChatOutputin their respective files, enabling users to specify a context identifier for chat sessions. [1] [2] [3]Propagation and usage of context ID:
AgentComponentto passcontext_idwhen fetching memory data, ensuring context-aware memory operations.message_responsemethods in bothChatInputandChatOutputto includecontext_idin the constructedMessageobjects, so that messages are tagged with the correct context throughout the chat pipeline. [1] [2]Input type update:
MessageTextInputfromlfx.ioinagent.pyto support the new context ID input type.Summary by CodeRabbit