-
Notifications
You must be signed in to change notification settings - Fork 207
More misc cleanup #1185
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
Merged
Merged
More misc cleanup #1185
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Assisted-By: cagent
Improves code consistency by using the more idiomatic Go pattern 'len(x) > 0' for checking non-empty slices instead of 'len(x) != 0'. Assisted-By: cagent
Replace the if-else branching with a direct call to min() for cleaner code. Assisted-By: cagent
…ressions Replace if-return chains with a single return statement using logical OR operators. Assisted-By: cagent
Remove redundant conditional logic in UserMessage. The MultiContent field can be set directly even when empty - Go handles nil/empty slices gracefully. This removes unnecessary branching and makes the code more readable. Assisted-By: cagent
…sages The isPathAllowed function already returns descriptive error messages. Wrapping them with 'Error:' is redundant and adds noise. Using err.Error() directly makes the code cleaner and error messages more consistent. Assisted-By: cagent
Replace the two-step HasSuffix check followed by TrimSuffix with the more idiomatic CutSuffix which does both in one operation. Also inline some match result checks for better readability. Assisted-By: cagent
Reduce vertical space in the match function by inlining the matched variable check. Assisted-By: cagent
Use fmt.Fprintf consistently instead of mixing WriteString/WriteByte. Combine the header lines into a single format string. Assisted-By: cagent
Reuse UserMessage function to reduce code duplication. ImplicitUserMessage now simply calls UserMessage and sets the Implicit flag to true. Assisted-By: cagent
Remove explicit AgentName: "" assignment since empty string is the zero value for strings in Go. Assisted-By: cagent
Create a shared helper function getLastMessageContentByRole to reduce code duplication between GetLastAssistantMessageContent and GetLastUserMessageContent. Assisted-By: cagent
Remove assertion for 'Error:' prefix that was removed in previous commit. The error messages are now more concise without the redundant prefix. Assisted-By: cagent
The thinkHandler struct was an unnecessary indirection. The thoughts slice can be stored directly on ThinkTool, simplifying the code. Assisted-By: cagent
The apiHandler struct and APIToolOption type were unnecessary indirection. The config can be accessed directly from the tool struct. Assisted-By: cagent
The if-block with early return can be simplified to a single boolean expression using ||. Assisted-By: cagent
The bubble sort implementation in sortResults was inefficient (O(n²)) and verbose. Using slices.SortFunc with cmp.Compare is both clearer and more efficient (O(n log n)). Assisted-By: cagent
Both GetSession and GetSessions had nearly identical code for scanning database rows into Session structs. This extracts the common logic into a scanSession helper function that accepts any scanner interface (Row or Rows). Assisted-By: cagent
The OAuth and elicitation handler setup code was duplicated in two places within RunStream. This extracts it into a single helper method. Assisted-By: cagent
Replace switch statement with a simpler map lookup pattern. This is more concise and equally readable. Assisted-By: cagent
Replace manual if statement with cmp.Or for selecting the current agent name. This is more idiomatic Go 1.21+ style. Assisted-By: cagent
The listTodos method was using a raw tool call handler signature while all other todo handlers use the typed NewHandler pattern. This change makes all todo handlers consistent. Assisted-By: cagent
The function name 'mcpToSortedList' was misleading since it simply returns sorted keys from a map, with no MCP-specific functionality. Renamed to 'sortedKeys' for clarity. Assisted-By: cagent
…sionStore The InMemorySessionStore methods take context.Context parameters for interface compliance but don't use them. Renamed to _ to make this explicit and satisfy linters. Assisted-By: cagent
Signed-off-by: David Gageot <david.gageot@docker.com>
trungutt
approved these changes
Jan 2, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.