Skip to content

parse ISO URL from streaming tool_result; refactor to pass C901#2779

Open
eliajahshan wants to merge 1 commit into
openshift:masterfrom
eliajahshan:chatbot-reading-links
Open

parse ISO URL from streaming tool_result; refactor to pass C901#2779
eliajahshan wants to merge 1 commit into
openshift:masterfrom
eliajahshan:chatbot-reading-links

Conversation

@eliajahshan
Copy link
Copy Markdown
Contributor

  • Summary

    • Extract the Discovery ISO URL from streaming SSE tool_result events and include it in the returned text.
    • Refactor send_query into small helpers to reduce McCabe complexity (fix flake8 C901) without changing behavior.
  • What changed

    • assisted-test-infra/src/chatbot_client.py
      • Added handling for event == "tool_result" with tool_name == "cluster_iso_download_url":
        • Parses nested JSON in data.token.response and appends the url to the response.
      • Split send_query into helpers (no behavior change):
        • _maybe_refresh_access_token, _build_payload
        • _send_streaming_query, _send_non_streaming_query
        • _parse_sse_line, _accumulate_event
        • _update_conversation_id, _append_token, _append_tool_result
      • Kept time-based token refresh and conversation ID handling.
      • Continued support for base URL (e.g., .../v1) via _resolve_endpoint.
      • Streaming behavior remains controlled by streaming_enabled (default True).
  • Why

    • The assistant may avoid printing the ISO URL directly, but exposes it via a tool result during streaming. Parsing this event lets tests retrieve the URL reliably.
    • Refactoring reduces complexity and satisfies flake8 C901 while keeping the public API stable.
  • Behavior and compatibility

    • Public API unchanged: ChatbotClient.send_query(question: str) -> str.
    • Existing callers continue to receive aggregated streaming text; now it will also include the ISO URL when available.
    • Supports both streaming and non-streaming endpoints; base /v1 URLs are resolved automatically.
  • Environment variables

    • OFFLINE_TOKEN (required)
    • ASSISTED_CHAT_API_URL (base e.g., https://assisted-chat.api.openshift.com/v1 or full endpoint)
    • CHATBOT_STREAMING_ENABLED (optional; default True)
  • Validation

    • For a cluster, ask for the Discovery ISO link; response should contain the pre-signed .iso URL.
    • Lint: flake8 src/chatbot_client.py (C901 resolved).
    • Non-streaming path still returns the single JSON response.
  • Notes

    • ISO URL parsing is defensive; ignores malformed tool payloads.
    • No changes to logging or request headers.

@openshift-ci openshift-ci Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 17, 2025
@openshift-ci openshift-ci Bot requested review from rccrdpccl and tsorya December 17, 2025 17:17
@openshift-ci openshift-ci Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 17, 2025
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Dec 17, 2025

Hi @eliajahshan. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Comment thread src/chatbot_client.py
@eliajahshan eliajahshan force-pushed the chatbot-reading-links branch from b770890 to 4807c28 Compare January 5, 2026 12:52
Copy link
Copy Markdown
Contributor

@eranco74 eranco74 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jan 20, 2026
@eliajahshan eliajahshan force-pushed the chatbot-reading-links branch from 4807c28 to f3aab36 Compare February 12, 2026 10:40
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 12, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Feb 12, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: eliajahshan
Once this PR has been reviewed and has the lgtm label, please ask for approval from eranco74. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@eliajahshan
Copy link
Copy Markdown
Contributor Author

/test lint

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Feb 12, 2026

@eliajahshan: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/test lint

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@eliajahshan
Copy link
Copy Markdown
Contributor Author

/retest

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Feb 12, 2026

@eliajahshan: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@eranco74
Copy link
Copy Markdown
Contributor

/ok-to-test

@openshift-ci openshift-ci Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 12, 2026
@eranco74
Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Feb 12, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Mar 11, 2026

@eliajahshan: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-metal-assisted-4-21 f3aab36 link true /test e2e-metal-assisted-4-21
ci/prow/e2e-metal-assisted-ha-kube-api-ipv4-4-22 f3aab36 link true /test e2e-metal-assisted-ha-kube-api-ipv4-4-22

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants