Skip to content

Conversation

@DOsinga
Copy link
Collaborator

@DOsinga DOsinga commented Jul 25, 2025

try to get a conversations into shape before we send them to the LLM

@DOsinga DOsinga requested review from baxen and jamadeo July 25, 2025 20:17

if messages.is_empty() {
issues.push("Added placeholder user message to empty conversation".to_string());
messages.push(Message::user().with_text(PLACEHOLDER_USER_MESSAGE));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this added in this method because it's the last method we call of the four from fix_conversation? Wondering if we could simply run this logic as part of that method instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the thinking is that if you have merged messages with the same role and then you've stripped any assistant messages from beginning and end, that you now have a conversation that starts with a user message and ends with one, unless we have no messages left. would you like me to call this method differently?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was just thinking in terms of https://en.wikipedia.org/wiki/Principle_of_least_astonishment fix_lead_trail would not also do this. I was thinking instead we'd do it as a separate method similar to the others

let (messages, empty_removed) = Self::remove_empty_messages(messages);
let (messages, tool_calling_fixed) = Self::fix_tool_calling(messages);
let (messages, messages_merged) = Self::merge_consecutive_messages(messages);
let (messages, lead_trail_fixed) = Self::fix_lead_trail(messages);
let (messages, populated_if_empty) = Self::populate_if_empty(messages);

Where populate_if_empty does just this part

if messages.is_empty() {
  issues.push("Added placeholder user message to empty conversation".to_string());
  messages.push(Message::user().with_text(PLACEHOLDER_USER_MESSAGE));
}

But it's not a huge difference! Just posting this to explain my thought

I think the branch has a ton of value as-is and should merge unless you prefer to also do this suggestion


if messages.is_empty() {
issues.push("Added placeholder user message to empty conversation".to_string());
messages.push(Message::user().with_text(PLACEHOLDER_USER_MESSAGE));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was just thinking in terms of https://en.wikipedia.org/wiki/Principle_of_least_astonishment fix_lead_trail would not also do this. I was thinking instead we'd do it as a separate method similar to the others

let (messages, empty_removed) = Self::remove_empty_messages(messages);
let (messages, tool_calling_fixed) = Self::fix_tool_calling(messages);
let (messages, messages_merged) = Self::merge_consecutive_messages(messages);
let (messages, lead_trail_fixed) = Self::fix_lead_trail(messages);
let (messages, populated_if_empty) = Self::populate_if_empty(messages);

Where populate_if_empty does just this part

if messages.is_empty() {
  issues.push("Added placeholder user message to empty conversation".to_string());
  messages.push(Message::user().with_text(PLACEHOLDER_USER_MESSAGE));
}

But it's not a huge difference! Just posting this to explain my thought

I think the branch has a ton of value as-is and should merge unless you prefer to also do this suggestion

@DOsinga
Copy link
Collaborator Author

DOsinga commented Jul 28, 2025

yeah I like it. will make it so

@DOsinga DOsinga merged commit 4442ccf into main Jul 28, 2025
8 checks passed
@DOsinga DOsinga deleted the fix-conversations-before-llm branch July 28, 2025 16:23
katzdave added a commit that referenced this pull request Jul 28, 2025
…cn/compact2-task-tracking

* 'dkatz/goose-compact2' of github.com:block/goose: (22 commits)
  rm stray files
  unused
  fmt
  fix threshold
  autocompact splice last message
  fmt
  Fix conversations before they hit the LLM (#3660)
  cli: add detailed instruction for WSL users (#3496)
  feat: recipe runs will now prompt for missing extension secrets (#3668)
  fix: pricing integration tests -> trying more runs for cache and retries (#3546)
  Add inline python extension (#3107)
  fix: add maintainer, homepage and categories to DEB/RPM package config (#3096)
  blog: agent to agent convo (#3677)
  Possible to disable random thinking messages (#3304)
  Two VS code tutorials (#3603)
  small blog fixes (#3549)
  docs: fix installation command for YouTube Transcript MCP in servers.json (#3595)
  Docs for using Docker Model Runner as a local LLM provider.  (#3509)
  Docs: VS Code Extension move to tutorials (#3601)
  Fix working directory when session has no messages (#3513)
  ...
michaelneale added a commit that referenced this pull request Jul 29, 2025
* dkatz/goose-compact2: (22 commits)
  rm stray files
  unused
  fmt
  fix threshold
  autocompact splice last message
  fmt
  Fix conversations before they hit the LLM (#3660)
  cli: add detailed instruction for WSL users (#3496)
  feat: recipe runs will now prompt for missing extension secrets (#3668)
  fix: pricing integration tests -> trying more runs for cache and retries (#3546)
  Add inline python extension (#3107)
  fix: add maintainer, homepage and categories to DEB/RPM package config (#3096)
  blog: agent to agent convo (#3677)
  Possible to disable random thinking messages (#3304)
  Two VS code tutorials (#3603)
  small blog fixes (#3549)
  docs: fix installation command for YouTube Transcript MCP in servers.json (#3595)
  Docs for using Docker Model Runner as a local LLM provider.  (#3509)
  Docs: VS Code Extension move to tutorials (#3601)
  Fix working directory when session has no messages (#3513)
  ...
michaelneale added a commit that referenced this pull request Jul 29, 2025
* main:
  blog: streamlining detection development w/ recipes (#3689)
  fix: have option for cli providers to use their configured or default model  (#3683)
  docs: new blog post and corrections to an old one on goosehints (#3657)
  Resolve sub recipe path relative to the parent recipe path (#3642)
  Speed up recipe loading from deeplinks and various fixes (#3662)
  fix cmd + , not opening settings (#3694)
  Add warning when JSON env parsing fails. (#3696)
  chore: refactor session naming into provider (#3678)
  feat (ui): File picker for scheduling recipes default to recipe dir (#3611)
  fix: address issue with streamable http interactions via mcp (#3693)
  Provider scenario tests (#3688)
  Fix conversations before they hit the LLM (#3660)
  cli: add detailed instruction for WSL users (#3496)
  feat: recipe runs will now prompt for missing extension secrets (#3668)
  fix: pricing integration tests -> trying more runs for cache and retries (#3546)
atarantino pushed a commit to atarantino/goose that referenced this pull request Aug 5, 2025
Co-authored-by: Douwe Osinga <[email protected]>
Signed-off-by: Adam Tarantino <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants