Skip to content

responseUrl support#96

Merged
dexhorthy merged 8 commits intohumanlayer:mainfrom
allisoneer:campy-things-allison
May 13, 2025
Merged

responseUrl support#96
dexhorthy merged 8 commits intohumanlayer:mainfrom
allisoneer:campy-things-allison

Conversation

@allisoneer
Copy link
Copy Markdown
Contributor

@allisoneer allisoneer commented May 13, 2025

Important

Adds support for sending task results to a specified ResponseUrl in TaskSpec, with tests for functionality and error handling.

  • Behavior:
    • Adds ResponseUrl field to TaskSpec in task_types.go to specify a URL for sending task results.
    • Updates task_controller.go to send final task results to ResponseUrl if specified.
    • Handles HTTP errors and connection issues when sending results.
  • Tests:
    • Adds send_response_url_test.go to test sending results to ResponseUrl, including error handling.
    • Adds task_responseurl_integration_test.go for integration testing of ResponseUrl functionality.
  • Dependencies:
    • Updates go.mod and go.sum to include necessary dependencies for HTTP requests and testing.

This description was created by Ellipsis for aa3c4c5. You can customize this summary. It will automatically update as commits are pushed.

Copy link
Copy Markdown
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Caution

Changes requested ❌

Reviewed everything up to aa3c4c5 in 2 minutes and 4 seconds. Click for details.
  • Reviewed 644 lines of code in 8 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. acp/internal/controller/task/task_controller.go:835
  • Draft comment:
    Consider reusing an HTTP client instead of creating a new one for every request to benefit from connection reuse and improved performance.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% Creating a new HTTP client for each request does prevent connection reuse and can impact performance. However, this function is only called once at the end of a task in a fire-and-forget goroutine. The performance impact is minimal since it's not in a hot path. The code is also simpler and more self-contained this way. The comment is technically correct - reusing HTTP clients is a best practice. There could be cases where many tasks complete simultaneously causing multiple HTTP clients to be created. Given this is a one-off request per task in a background goroutine, the performance impact is negligible. The current approach favors simplicity and isolation over minor performance optimization. While technically correct, the comment suggests an optimization that would add complexity for minimal benefit in this specific case. The current implementation is appropriate for its usage pattern.
2. acp/internal/controller/task/task_controller.go:474
  • Draft comment:
    The goroutine launching the HTTP request for responseUrl is non-blocking which is appropriate; however, ensure that high volume of tasks doesn’t lead to unmonitored goroutines and resource exhaustion.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the author to ensure that a high volume of tasks doesn't lead to unmonitored goroutines and resource exhaustion. This is a general caution and not a specific code suggestion or question about the code's intention. It doesn't provide a specific action or suggestion for improvement.
3. acp/internal/controller/task/task_responseurl_integration_test.go:148
  • Draft comment:
    Integration test simulates the full task lifecycle with responseUrl effectively. Ensure that shared globals (e.g., testAgent and k8sClient) are reliably initialized to prevent potential test flakiness.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the author to ensure that shared globals are reliably initialized, which is a form of asking the author to double-check their work. This violates the rule against asking the author to ensure behavior is intended or tested.
4. acp/internal/controller/task/task_controller.go:847
  • Draft comment:
    When a non-success HTTP status code is returned, the function constructs an error including the response body. Consider logging additional context (or using structured logging) to aid in troubleshooting these failures.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The code already has good error handling practices: 1) It includes status code and response body in error 2) Logs before returning with responseUrl context 3) Caller also logs with responseUrl context. Additional structured logging would be redundant since the key information is already captured and logged. The comment has a point that structured logging can be better than string formatting. And there could be additional context like request headers or timing that could be useful. While structured logging is good practice, the current implementation already captures and logs the essential information needed for debugging HTTP failures. The suggested changes would be minor improvements at best. The comment should be deleted as the code already has sufficient error handling and logging. The suggested improvements would be minimal and not worth the change.
5. acp/internal/controller/task/task_controller.go:500
  • Draft comment:
    The variable 'toolCallRequestId' is used here, but elsewhere the field is named 'ToolCallRequestID'. Consider renaming it to 'toolCallRequestID' for consistency with Go's acronym naming conventions.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
6. acp/internal/controller/task/task_responseurl_integration_test.go:106
  • Draft comment:
    Typographical suggestion: Consider renaming 'ResponseUrl' to 'ResponseURL' to maintain consistency with common Go conventions for acronyms. This is a minor style issue and does not affect functionality.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% While the suggestion follows Go conventions for acronyms, this appears to be a field name from an imported type (acp.TaskSpec). Changing it in the test would create inconsistency with the actual API type. The naming convention should be addressed in the API definition, not in the test that uses it. Additionally, this is a test file, so the impact of the naming inconsistency is minimal. The comment correctly identifies a Go naming convention issue. Perhaps there's value in fixing this across the entire codebase starting with tests? No, changing just the test would create more inconsistency. This should be addressed at the API type level, not in individual test files that use the API. Delete the comment. While the naming suggestion is technically correct, changing it just in the test would create inconsistency with the actual API type definition.

Workflow ID: wflow_nR6yjUs58bFl3nDd

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Comment thread acp/api/v1alpha1/task_types.go Outdated
// ResponseUrl specifies a pre-generated URL that will be used for human contact responses.
// This allows the system to direct responses to a specific endpoint.
// +optional
ResponseUrl string `json:"responseUrl,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The new field ResponseUrl uses Url where the acronym URL is typically expected to be fully uppercased. For consistency with common Go naming conventions for acronyms (like ID in ToolCallID), consider renaming it to ResponseURL.

Suggested change
ResponseUrl string `json:"responseUrl,omitempty"`
ResponseURL string `json:"responseURL,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

plz do this

err := r.sendFinalResultToResponseUrl(sendCtx, task.Spec.ResponseUrl, output.Content)
if err != nil {
// Just log error, don't fail the task
logger.Error(err, "Failed to send final result to responseUrl",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does this exist ?

body, _ := io.ReadAll(resp.Body)
return fmt.Errorf("received non-success status code: %d, body: %s", resp.StatusCode, string(body))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

emit an event here?


// If task has a responseUrl, send the final result to that URL
if task.Spec.ResponseUrl != "" {
go func() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why are we doing go func()

@dexhorthy dexhorthy merged commit 3769984 into humanlayer:main May 13, 2025
5 checks passed
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