-
Notifications
You must be signed in to change notification settings - Fork 855
feat(aiagent): allow giving messages history #7395
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
base: main
Are you sure you want to change the base?
Conversation
Deploying windmill with
|
| Latest commit: |
4b338f6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9969e789.windmill.pages.dev |
| Branch Preview URL: | https://fg-arraymessages.windmill.pages.dev |
|
Claude finished @centdix's task in 3m 38s —— View job Code Review Completed ✅I've completed a comprehensive review of PR #7395 which adds support for providing message history to AI agents. This is a valuable feature that allows users to bypass the built-in memory system and provide custom conversation histories. SummaryThis PR adds a new Key Changes:
Code Quality Assessment✅ Strengths
|
| if let Some(ref explicit_messages) = args.messages { | ||
| if !explicit_messages.is_empty() { | ||
| // Use explicitly provided messages (bypass memory) | ||
| messages.extend(explicit_messages.clone()); |
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.
Performance: Unnecessary clone
This .clone() allocates memory for the entire messages array. Since args.messages is never used after this point, consider taking ownership instead.
If you can make args mutable, you could use:
if let Some(explicit_messages) = args.messages.take() {
if !explicit_messages.is_empty() {
messages.extend(explicit_messages);
}
}This avoids the allocation, which could be significant for large message histories.
|
|
||
| // Validate: at least one of messages or user_message must be provided | ||
| if !use_explicit_messages && !has_user_message { | ||
| return Err(Error::internal_err( |
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.
Edge case: Consider image output type
When output_type is Image, the user might not provide user_message (since the description states tools and messages are ignored for image generation). However, this validation would still trigger an error.
Consider either:
- Exempting image output from this check
- Making the error message more specific
- Ensuring the frontend prevents this invalid state
| messages: { | ||
| type: 'array', | ||
| description: | ||
| 'An array of conversation messages to use as history. When provided, these messages replace any messages that would be loaded from memory, and memory will not be updated at the end of the run. If user_message is also provided, it will be appended as the final message.', |
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.
Documentation clarity
Consider clarifying the interaction with system_prompt:
description:
'An array of conversation messages to use as history. When provided, these messages replace any messages that would be loaded from memory, and memory will not be updated at the end of the run. Note: system_prompt, if provided, will be prepended as the first message. If user_message is also provided, it will be appended as the final message.',This makes the complete behavior clear to users.
| const dispatchIfMounted = createDispatcherIfMounted(dispatch) | ||
| function parseJson() { | ||
| try { |
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.
Good fix!
This change properly handles the empty string case by setting value = undefined and clearing the error, while the else branch handles the parsing. This is cleaner than the previous early return pattern.
|
/ai change the input schema of the ai agent, instead of adding |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
ab00ab0 to
f3d5d36
Compare
|
/ai change the input schema of the ai agent, instead of adding messages array, we want to have a history field, which is a oneOf. |
|
Claude finished @centdix's task in 11m 37s —— View job AI Agent Schema Changes Complete ✅Successfully replaced the Summary of ChangesBackend (Rust):
Frontend (TypeScript/Svelte):
Validation:
Commits
Backward CompatibilityThe changes maintain full backward compatibility:
--- | |
…oneOf field Replace the separate 'messages' array and 'messages_context_length' fields with a single 'history' field that uses a oneOf discriminator. The 'history' field can be either: - 'auto' mode: automatically manages conversation history with memory, takes a 'context_length' number parameter - 'manual' mode: bypasses memory and uses explicitly provided messages array Backward compatibility is maintained: if 'messages_context_length' is provided in the old schema format, it is automatically converted to 'auto' mode with the specified context_length. Co-authored-by: centdix <[email protected]>
… oneOf field
Replace the separate 'messages' array and 'messages_context_length' fields with
a single 'history' field in the AI agent schema.
The 'history' field uses a oneOf discriminator with two modes:
- 'auto': { mode: 'auto', context_length: number } - automatically manages
conversation history with memory
- 'manual': { mode: 'manual', messages: array } - bypasses memory and uses
explicitly provided messages
The schema includes comprehensive descriptions for each mode explaining the
behavior. The order array has been updated to include 'history' in place of
the old 'messages_context_length' and 'messages' fields.
Co-authored-by: centdix <[email protected]>
Update ArgInput.svelte to properly handle oneOf schemas that use 'mode' as the discriminator field, in addition to the existing 'kind' and 'label' support. Changes: - Updated tagKey derivation to check for 'mode' first, then 'kind', then 'label' - Added 'mode' to the onOneOfChange function to track mode changes - Added 'mode' to the list of keys excluded from enum validation - Added 'mode' to hiddenArgs to prevent it from being shown in the form - Added title fields to the history oneOf variants in flowInfers.ts This allows the AI agent's history field to properly render with toggle buttons for 'auto' and 'manual' modes. Co-authored-by: centdix <[email protected]>
Enregistrement.de.l.ecran.2025-12-16.a.21.35.03.mov