Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ the resolved home and forwards `config_present` plus the loaded
every decision: a present config is authoritative, and a present-but-invalid
config source fails closed with no env fallback; a missing config falls back
to `RUSTSCRIPT_AGENT_SOURCE`, then the deprecated `RUSTSCRIPT_AGENT_SCRIPT`,
then the bundled coding entry.
then the bundled coding entry. The same loaded document supplies the gateway's
default `model.provider`/`model.model` and registers each configured provider's
public `protocol`, `base_url`, and optional named `auth` credential ID as a
`ProviderProfile` before the listener binds. A missing document keeps the
built-in `local-agent` defaults; an invalid provider profile fails startup.
The operator provider factory uses headless native HTTPS and never opens a
browser or a callback listener; the workspace host still receives no OAuth
transport.

The gateway rejects a blank value. When the workspace host resolves the home,
`AgentPaths` requires a non-empty absolute path with no parent-directory
Expand Down
41 changes: 40 additions & 1 deletion rss/agent/main.rss
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,46 @@ fn seed_messages(context: map, messages: array) -> array {
seeded
}

// Native `RunContext.tool_schemas` entries are validated registry
// `ToolDescriptor` maps (`{name, description, toolset, risk_class, schema}`).
// The canonical LlmRequest contract still carries the schema as a JSON string
// in `schema_json`, which the Chat/Gemini/Anthropic codecs splice into their
// wire bodies; convert only at this boundary so native and canonical shapes
// stay distinct everywhere else.
fn native_tool_to_canonical(descriptor: map) -> map {
let schema: map = descriptor["schema"];
let schema_json: string = json::encode(schema);
{
name: ctx_string(descriptor, "name", ""),
description: ctx_string(descriptor, "description", ""),
schema_json: schema_json
}
}

fn native_tools_to_canonical(descriptors: array) -> array {
let mut tools: array = [];
let mut index = 0;
while index < descriptors.length {
let descriptor: map = array_map(descriptors, index);
tools[tools.length] = native_tool_to_canonical(descriptor);
index += 1;
}
tools
}

fn tools_from_context(context: map) -> array {
let mut tools: array = ctx_array(context, "tools");
if tools.length == 0 {
let native_descriptors: array = ctx_array(context, "tool_schemas");
tools = native_tools_to_canonical(native_descriptors);
}
tools
}

// Local tool dispatch and admitted-registry authority consume the native
// descriptor shape (risk class, toolset, schema object); it must not see the
// canonical LLM conversion above.
fn native_tools_from_context(context: map) -> array {
let mut tools: array = ctx_array(context, "tools");
if tools.length == 0 {
tools = ctx_array(context, "tool_schemas");
Expand Down Expand Up @@ -613,7 +652,7 @@ fn dispatch_reviewed(context: map, call: map) -> map {
let identity: string = ctx_string(metadata, "registry_identity", "");
let dispatch_input: map = {
call: call,
registry: tools_from_context(context),
registry: native_tools_from_context(context),
registry_identity: identity,
admitted_registry_identity: identity,
run_id: ctx_string(context, "run_id", ""),
Expand Down
27 changes: 25 additions & 2 deletions rss/llm/openai_chat.rss
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ struct WireMessage {
tool_calls: array<WireToolCall>?
}

struct WireToolError {
error: string,
message: string,
content: string
}

struct WireStreamOptions {
include_usage: bool
}
Expand Down Expand Up @@ -228,7 +234,7 @@ fn chat_append_user_message(wire: array<WireMessage>, message: map, index: int)
if part.has("type") {
if types::part_type(part) == "tool_result" {
let tool_call_id: string = types::request_string(part, "tool_call_id");
let content: string = types::request_string(part, "content");
let content: string = chat_tool_result_output(part);
result[result.length] = {
role: "tool",
content: content,
Expand All @@ -251,6 +257,22 @@ fn chat_append_user_message(wire: array<WireMessage>, message: map, index: int)
result
}

/// Preserve public failure details when a tool produced no text output.
fn chat_tool_result_output(part: map) -> string {
let content: string = types::request_string(part, "content");
if types::request_bool(part, "is_error", false) => {
let error: map = types::request_map(part, "error");
let failure: WireToolError = {
error: types::request_string(error, "code"),
message: types::request_string(error, "message"),
content: content
};
json::encode(failure)
} else => {
content
}
}

/// The `[{type: "text", text}]` parts of one canonical user message.
fn chat_user_text_parts(message: map) -> array<WireTextPart> {
let parts: array = types::message_content(message);
Expand Down Expand Up @@ -485,10 +507,11 @@ fn chat_parse_message(
/// (chat completions) or an array of `{type, text}` parts (Responses,
/// Anthropic-style transcripts). Part arrays are joined over their text-ish
/// parts (`text`/`output_text`).
/// Tool-call-only assistant messages may omit content and contribute no text.
fn chat_message_text(message: map) -> string {
let direct: string = types::request_string(message, "content");
let mut text: string = direct;
if type(message["content"]) == "array" {
if message.has("content") && type(message["content"]) == "array" {
let parts: array = message["content"];
let mut joined: string = "";
let mut i = 0;
Expand Down
11 changes: 7 additions & 4 deletions rss/tools/dispatch.rss
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,14 @@ pub fn approval_context(input: map) -> map {
result
}

/// Create a terminal typed tool result for Guardian/replay admission failures.
/// Denied or unavailable reviews become failed tool observations, not grants.
/// Broken run authority, replay, storage and cancellation still stop the run.
pub fn approval_failure(input: map, code: string, message: string) -> map {
let mut failure: map = fail_envelope(call_from_input(input), code, message, true);
// This trusted approval boundary always stops the run; ordinary tool
// errors retain their existing code-based recoverability below envelope.
failure.terminal = true;
let recoverable: bool = code == "guardian_denied"
|| code == "guardian_policy_denied"
|| code == "guardian_malformed_assessment"
|| code == "guardian_provider_failed";
failure.terminal = !recoverable;
failure
}
Loading
Loading