Skip to content

RDBC-1151 RavenDB-24824 Add per-call output schema override and string output for AI conversations - #318

Merged
poissoncorp merged 3 commits into
ravendb:v7.2from
poissoncorp:sdk-sync/RDBC-1151
Oct 22, 2026
Merged

poissoncorp merged 3 commits into
ravendb:v7.2from
poissoncorp:sdk-sync/RDBC-1151

Conversation

@poissoncorp

@poissoncorp poissoncorp commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

AI conversations can now override the output schema for one turn with a schema string or a sample object, get plain text answers with run_text() and stream_text(), and register tools that take no parameters.

  • Changed: run_with_schema and stream_with_schema accept an AiOutputOptions, a JSON schema string or a sample object (dict or entity). New run_text(), stream_text(on_chunk), handle_no_args() and receive_no_args() on AiConversation. RunConversationCommand streams whenever stream_property_path is not None, so a no-schema turn can stream with an empty path, as in C#.
  • Already present: AiOutputOptions, OutputOptions in the request body and string Response parsing.
  • Not ported: checks of the options against the answer type, because Python answers are untyped (the no_schema and schema conflict is already rejected by AiOutputOptions). Sync and async overload pairs and expression-based paths are C#-specific.
  • Tests: test_ai_output_options.py gains schema shorthand, raw text and no-args tool tests with mocked conversation calls, adapted from RavenDB_24824. The RavenDB_24824 tests that need a live OpenAI connection are not ported.
  • Checks: black --check . passed; test_ai_output_options passed (31); ai_agent_tests passed, and the tests that need a server run only in CI.

Decision needed

Python has no overloading, and run() already means "use the agent's schema", so the C# overloads need names.

  1. Separate methods run_text(), stream_text(), handle_no_args(), receive_no_args() (recommended, this PR): explicit, and existing signatures stay the same.
  2. An optional output_options argument on run() and stream(), as in the Node.js client.
  3. handle() and receive() check the handler's parameter count instead of new methods.

Existing behavior that this PR does not change: add_action_response keeps only string results, so a handler that returns a dict sends no content, while C# serializes it to JSON.


Ticket: RDBC-1151
C# change: ravendb/ravendb#22632

SDK Sync Agent

@poissoncorp poissoncorp added the sdk-sync Port of C# client changes from an SDK sync task label Oct 7, 2026
@poissoncorp
poissoncorp marked this pull request as ready for review October 7, 2026 12:24
@poissoncorp

Copy link
Copy Markdown
Contributor Author

The failing check is not caused by this PR. No code change.

A rerun of the failed job should pass. If it fails again, the secured test server setup in CI needs a look.

SDK Sync Agent

@poissoncorp

poissoncorp commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

please fix failing/flaky test as well and rebase other PRs after merge

The worker waits 5 seconds before it reconnects, so a failed first
connection attempt made the 4 second wait time out.
@poissoncorp

Copy link
Copy Markdown
Contributor Author

Fixed the flaky secured subscription tests in 19fd21f.

SDK Sync Agent

@poissoncorp

Copy link
Copy Markdown
Contributor Author

fix failing test

@poissoncorp

Copy link
Copy Markdown
Contributor Author

Fixed the failing test_more_like_this in 83f176c.

  • Cause: posts/3 and posts/4 each share one term with posts/1, and both terms occur in three documents, so the two posts score almost the same. The latest 7.2 nightly server returns them in the other order. The test asserted a fixed order.
  • Fix: posts/2 must still be the first result; the other two results may come in either order.
  • The same failure is on all Python versions of RDBC-1162 RavenDB-27614 Generate and validate identifiers for server-wide AI connection strings #319 and RDBC-1161 RavenDB-27289 Require a value for every declared agent parameter #320, which do not touch indexing or queries. Those PRs pick up the fix when they are updated from v7.2 after this PR is merged.
  • The Java client asserts the same fixed order. If the new order is a server regression rather than a scoring change, the server team has to look at it; the test no longer reports it.
  • The test needs a server and ran only in CI. black --check passed.

SDK Sync Agent

@poissoncorp
poissoncorp merged commit 63c2db0 into ravendb:v7.2 Oct 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk-sync Port of C# client changes from an SDK sync task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant