experimental genie ask: multi-turn conversations via --session/-s#5762
Open
lennartkats-db wants to merge 17 commits into
Open
experimental genie ask: multi-turn conversations via --session/-s#5762lennartkats-db wants to merge 17 commits into
lennartkats-db wants to merge 17 commits into
Conversation
…g header The /api/2.0/data-rooms/tools/onechat/responses endpoint is workspace-scoped. Without the org-id header the gateway rejects the request with "Credential was not sent or was of an unsupported type for this API" even when auth is otherwise valid (reproduced live on dogfood). Resolve it from cfg.WorkspaceID and send it, matching how workspace-scoped routing works elsewhere. Co-authored-by: Isaac
…e ask
--conversation continues a prior conversation: the request field is camelCase
conversationId carrying the conversation_id from response.completed (the backend
ignores the snake_case form; verified live). The id is surfaced as a text footer
and in --output json so the next turn can use it.
A scoped signal.NotifyContext makes Ctrl-C cancel the stream cleanly ("Cancelled.",
exit 1) rather than dumping "context canceled"; kept distinct from the stall path.
Stacked on the X-Databricks-Org-Id header fix.
Acceptance: the JSON golden gains conversation_id (updated here); the text-mode
sections also gain a "Continue this conversation" footer that still needs
regenerating with 'go test ./acceptance -run TestAccept/experimental/genie/ask
-update' (requires jq>=1.7, unavailable where this was built).
Co-authored-by: Isaac
Switch the workspace routing header from the hardcoded legacy X-Databricks-Org-Id to the canonical auth.WorkspaceIDHeaders helper (X-Databricks-Workspace-Id), matching how `databricks api` and the SDK route workspace-scoped calls. Re-verified live on dogfood; tests assert the canonical header. Co-authored-by: Isaac
Propagate the canonical-header fix onto this stacked branch (matching the org-id fix PR) so merging it doesn't regress the routing header. Sends X-Databricks-Workspace-Id; tests assert it. Co-authored-by: Isaac
The auth.WorkspaceIDHeaders call sites elsewhere carry no comment; this one shouldn't either. Co-authored-by: Isaac
Co-authored-by: Isaac
Advance the stack base so this PR's diff shows only the multi-turn + Ctrl-C changes, not the header fix it builds on. Co-authored-by: Isaac
--conversation/-c now takes a client-chosen label (any string) instead of a server conversation id. The label maps to the server conversation id in a local cache (libs/cache, keyed by host+label), so follow-ups just reuse the same label: genie ask -c q3 'what tables are in samples.wanderbricks?' genie ask -c q3 'how many did you just list?' The server only accepts conversation ids it generated, so a label that maps to an expired/unknown id fails open: the command forgets the dead mapping, notes it on stderr, and retries as a fresh conversation. Drops the stdout/stderr footer. Co-authored-by: Isaac
…rchestration Move the label->server-conversation-id map from libs/cache to ~/.databricks/genie-conversations.json, matching the cmd/sandbox/state.go store pattern (0600 file / 0700 dir, atomic tmp+rename, per-entry TTL, fails open). Extract the resolve/fail-open/store flow into askWithConversation so it is unit tested directly: first-use stores, reuse refreshes, a dead mapping fails open (forget + retry fresh), output-before-error is not retried, and a cancel keeps the mapping. Co-authored-by: Isaac
-c is the conventional short flag for --continue, so reserve it (and avoid the clash) by naming the session-label flag --session/-s instead. Co-authored-by: Isaac
Match the filestore.go atomic-write idiom: defer Close, tmp.Chmod on the handle. No behavior change. Co-authored-by: Isaac
- Rename label -> session id throughout; store maps sessionId -> conversationId. - Store as a nested host -> sessionId -> entry map (drops the host+"\n"+label key). - Windows-safe store path via filepath.Join(home, ".databricks", ...). - Cancel on SIGTERM as well as SIGINT (agents stop children with SIGTERM). - Warn on stderr when --session is combined with --raw (no conversation tracked). - Recover from a corrupt store file (treat as empty); add a regression test. - Doc cleanups: Returns-style render comments, clearer warehouse-id note, trim others. Co-authored-by: Isaac
Resolves the phantom conflict in client_test.go (#5735 squash-merged into main while this branch carries the same header fix via merge): keep this branch's version, which uses the updated 3-arg BuildRequest signature. Co-authored-by: Isaac
Collaborator
Integration test reportCommit: 0c0b043
23 interesting tests: 13 SKIP, 7 KNOWN, 3 flaky
|
…rror The multi-turn work surfaces conversation_id in --output json; the protocol-drift acceptance golden still expected the pre-conversation_id error shape. Add the captured conversation_id line so the golden matches actual output. Co-authored-by: Isaac
…log) Co-authored-by: Isaac
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
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.
Changes
Adds multi-turn conversations to
databricks experimental genie ask:-s, --session <label>continues a conversation across calls. The label is any string you pick; it maps to the server conversation id in a local store (~/.databricks/genie-conversations.json, same pattern ascmd/sandbox/state.go), so you never copy an id around:kill(SIGINT + SIGTERM) cancel the stream cleanly instead of dumpingcontext canceled— SIGTERM matters because agents stop child processes with it.Tests
Unit tests for the store (round-trip, host scoping, TTL, corrupt-file recovery) and the resolve/fail-open/store orchestration (first-use, reuse, dead-mapping retry, error-after-output, cancel). Verified live on dogfood: reuse threads context, distinct labels stay independent, a seeded dead mapping fails open + remaps, parallel different-label sessions are independent, and SIGINT/SIGTERM exit cleanly.