🩹 fix: Scoped Token-Config Fallback and Sequential Visibility for Usage Events

This commit is contained in:
Danny Avila 2026-06-11 14:17:17 -04:00
parent 7489c2be8c
commit 84436aa688
2 changed files with 14 additions and 4 deletions

View file

@ -30,8 +30,11 @@ async function tokenConfigController(req, res) {
endpointTokenConfigs[name] = endpointConfig.tokenConfig;
continue;
}
/** The models-config fetch path stores under the plain endpoint name;
* chat initialization stores under the user-scoped key accept either */
const tokenKey = getTokenConfigKey(endpointConfig, name, req.user.id);
const cached = await cache.get(tokenKey);
const cached =
(await cache.get(tokenKey)) ?? (tokenKey !== name ? await cache.get(name) : undefined);
if (cached) {
endpointTokenConfigs[name] = cached;
}

View file

@ -464,12 +464,19 @@ function getDefaultHandlers({
if (GraphEvents.ON_CONTEXT_USAGE) {
handlers[GraphEvents.ON_CONTEXT_USAGE] = {
/**
* Forward per-model-call context usage snapshots to the client.
* Forward per-model-call context usage snapshots to the client,
* honoring the same sequential-agent visibility gate as deltas.
* @param {string} event - The event name.
* @param {StreamEventData} data - The event data.
* @param {GraphRunnableConfig['configurable']} [metadata] The runnable metadata.
*/
handle: async (event, data) => {
await emitEvent(res, streamId, { event, data });
handle: async (event, data, metadata) => {
if (
checkIfLastAgent(metadata?.last_agent_id, metadata?.langgraph_node) ||
!metadata?.hide_sequential_outputs
) {
await emitEvent(res, streamId, { event, data });
}
},
};
}