import { ensureRuntimeMetadata } from '../conversion/runtime-metadata.js';
export async function reenterServerToolBackend(args) {
    const routeHint = typeof args.routeHint === 'string' && args.routeHint.trim().length ? args.routeHint.trim() : undefined;
    const merged = {
        providerProtocol: args.providerProtocol,
        stream: false,
        ...(routeHint ? { routeHint } : {}),
        ...(args.metadata ?? {})
    };
    const rt = ensureRuntimeMetadata(merged);
    rt.serverToolFollowup = true;
    rt.preserveRouteHint = false;
    rt.disableStickyRoutes = true;
    return await args.reenterPipeline({
        entryEndpoint: args.entryEndpoint,
        requestId: args.requestId,
        body: args.body,
        metadata: merged
    });
}
