Skip to content

feat(environments): show package policy and Anaconda sign-in failures in the chat - #165

Draft
romulorosa wants to merge 8 commits into
kilo/implement-policy-channel-error-handling-and-nfrom
kilo/policy-chat-card
Draft

romulorosa wants to merge 8 commits into
kilo/implement-policy-channel-error-handling-and-nfrom
kilo/policy-chat-card

Conversation

@romulorosa

@romulorosa romulorosa commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #163 (error codes, agent guidance, PolicyErrorDetails, payload 0.1.23). Review only the last four commits.

What

  • kilo.chat (generic, no conda knowledge): a kilo.chat/tool-renderer implementation can now answer isStandalone(call). The calls it picks stay out of the activity groups and the settled turn's fold, the same way the static standalone metadata keeps every call of a tool out. kilo.chat asks the tool's highest-priority renderer. If the predicate throws, the call is grouped as usual, so one plugin's bug can't break the transcript's grouping. toolResultText(result) (a string, or an MCP result's text content) is now exported from the chat contracts, and the sign-in card uses it too.

  • kilo.environments: contributes the conda-policy tool renderer for conda.envs.create, conda.envs.clone, conda.packages.install, conda.packages.update, conda.packages.remove and conda.repodata.find. When a call fails with one of these, it renders as a card (environments-chat-policy-card):

    • POLICY_BLOCKED;
    • SOLVE_FAILED with policyNote;
    • NOT_SIGNED_IN / CHANNEL_ACCESS_DENIED.

    The card reads what is blocked, why, by whom, then what to do, each once. A blocked install shows pillow 8.4.0 is blocked, then by acme's package policy · organization_policy, then the platform's reason verbatim in its own block, then the next step ("Ask your organization's administrator for an exception…"). Several blocks show "3 packages are blocked" and one row per package (name and version, reason), and a row names its org or policy only when the subline doesn't. A policy-note solve failure shows "Couldn't resolve the packages". Sign-in refusals lead with the channel ("Sign in to Anaconda to use acme/main", "Your Anaconda account can't use …"), with a "Sign in to Anaconda" button that turns into "Signed in. Ask the agent to try again." The default row and the solver text sit under a quiet "Details" toggle. PolicyErrorDetails exports its sign-in as useAnacondaSignIn so the card can draw its own button. Settings renders as before. Only these calls stand alone. Every other call, and every success, renders exactly as before.

  • Agent text: the conda kilo.core/chat-config contribution adds an instruction for Kilo's chats: the card already shows these details, so the agent replies in one short sentence with the next step and doesn't repeat the package, channel, org, policy or reason. POLICY_GUIDANCE in the tool descriptions, which external MCP clients without the card also read, keeps the verbatim report "unless your instructions say the chat already shows these details". Never routing around a block and never asking for a token are unchanged.

  • Docs: docs/plugins/chat-and-tools.md documents isStandalone and toolResultText, and pnpm docs:schema was regenerated.

Why

With #163 the agent gets structured policy and sign-in errors. In the transcript, though, those failures were still a one-line row folded into "Worked for …". People couldn't see which package was blocked, which policy blocked it or why, and they had no way to sign in to Anaconda from there. The card keeps these failures in sight and actionable, and the change to kilo.chat stays generic.

Tests

  • pnpm lint, pnpm format:check, pnpm check: pass.
  • @kilo-desktop/plugin-chat coverage (unit + browser): 118 files / 1005 tests pass. Statements 94.3%, branches 83%, functions 92%, lines 96.3%.
    • New: toolResultText (helpers.test.ts), the toolkit publishing per-call standalone questions (toolkit.test.ts), grouping and fold, including a throwing predicate (activity-grouping.test.ts), and a contributed renderer whose failed call stays out of the fold while its successful call folds (tools.browser.test.tsx).
  • @kilo-desktop/plugin-environments coverage (unit + integration + browser): 48 files / 998 tests pass. Statements 96.1%, branches 87.4%, functions 92.7%, lines 97.1%.
    • New: manifest contribution test, condaPolicyFailure unit tests, and policyCardContent unit tests (headlines, shared vs per-row org/policy, null fields, the summary fallback, channel shortening). Browser tests for the card cover a single block with nothing said twice, three blocks with mixed policies and null fields, a policy note, sign-in success and failure, no button without kilo.anaconda, and the fallback for other errors and successes. Entry and tools tests check the chat instruction and the conditional guidance.
    • Checked by eye with local screenshots of every state in light and dark (not committed).

Live test (payload 0.1.23, pnpm dev, environments-feature on, an API key scoped to a policy org)

  • The agent installs pillow=8.4.0 on defaults: the transcript shows the policy card with the package, policy, org and reason, outside the fold after the turn settles.
  • Signed out of Anaconda, the same install shows the "Sign in to Anaconda" card. The button opens the Anaconda browser sign-in, and asking the agent to retry then works.
  • conda.repodata.find on that channel while signed out shows the sign-in card naming the refused channel.
  • holoviews on the org's policy channel shows the "Couldn't resolve the packages" card.
  • After a block, the agent's reply is one short sentence with the next step and doesn't repeat what the card shows.
  • Other conda tool failures and successes still render as one-line rows inside the fold.

A kilo.chat/tool-renderer implementation may answer isStandalone(call) to
keep only some of a tool's calls (a failure the person can act on) out of
the activity groups and the settled turn's fold, as the static standalone
metadata does for every call. The tool's first renderer is asked; a
question that throws leaves the call where it would be.

toolResultText (a string, or an MCP result's text content) moves to the
contracts so renderers read tool output the way the sign-in card does.
kilo.environments contributes a kilo.chat/tool-renderer for the conda tools
that resolve packages (envs.create/clone, packages.install/update/remove,
repodata.find). A failed call whose message is a package-policy block, a
solve failure with a policy note, or an Anaconda sign-in refusal
(NOT_SIGNED_IN / CHANNEL_ACCESS_DENIED) becomes a card: its title, the
message, PolicyErrorDetails (blocked packages verbatim, the policy note,
Sign in to Anaconda) and, after sign-in, a prompt to ask the agent to try
again; the default row and solver text stay under Details. Only those calls
stand alone outside the activity groups and the turn's fold; every other
call renders as before.
The card now reads what is blocked, why, by whom, and what to do next,
each once: a headline naming the package (or the count), a subline with
the org and policy, the platform's reason in its own block, then the next
step with a quiet Details toggle. Several blocks list one row each, naming
an org or policy only when the subline does not. Sign-in refusals lead
with the channel and a Sign in to Anaconda button that turns into
"Signed in. Ask the agent to try again."

PolicyErrorDetails exports its sign-in as useAnacondaSignIn so the card
draws its own button; Settings renders as before.
Kilo's chats get an instruction through the conda chat config: the card
already shows the blocked packages, policy, org, reason and sign-in, so
the agent replies with one short sentence and the next step. The tool
descriptions, which also reach external MCP clients without the card,
keep the verbatim report unless the instructions say the chat shows it.
…ror-handling-and-n' into kilo/policy-chat-card

# Conflicts:
#	plugins/environments/src/main/tools.test.ts
#	plugins/environments/src/main/tools.ts
…ror-handling-and-n' into kilo/policy-chat-card
…ror-handling-and-n' into kilo/policy-chat-card

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant