xai-org/grok-build · error · acp::Error
InternalError
InternalError
Error message
e.to_string()
What it means
handle_btw maps an unclassified SideQuestionError to an ACP error with ErrorCode::InternalError and the error's Display string (feedback.rs:73-76). Only the Sampling variant gets specific handling; every other side-question failure (channel closed, session gone, unexpected internal state) surfaces as this generic InternalError.
Source
Thrown at crates/codegen/xai-grok-shell/src/extensions/feedback.rs:73
acp::Error::invalid_params().data(format!("session not found: {}", req.session_id))
);
};
let (tx, rx) = oneshot::channel();
let _ = session.cmd_tx.send(SessionCommand::SideQuestion {
question: req.question,
respond_to: tx,
});
let result = rx
.await
.map_err(|_| acp::Error::internal_error().data("session failed to respond"))?;
match result {
Ok(answer) => super::to_ext_response(Ok(serde_json::json!({
"answer": answer,
}))),
Err(SideQuestionError::Sampling(e)) => {
Err(crate::sampling::error::map_sampling_err_to_acp(e))
}
Err(e) => Err(acp::Error::new(
acp::ErrorCode::InternalError.into(),
e.to_string(),
)),
}
}
async fn handle_feedback(agent: &MvpAgent, args: &acp::ExtRequest) -> ExtResult {
if !agent.cfg.borrow().is_feedback_enabled() {
return Err(acp::Error::internal_error().data(
"Feedback is disabled. To enable, set GROK_FEEDBACK_ENABLED=true or \
[features] feedback = true in config.toml.",
));
}
match args.method.as_ref() {
"x.ai/feedback" => {
let mut feedback_input: ClientFeedbackInput =
match serde_json::from_str::<ClientFeedbackInput>(args.params.get()) {
Ok(input) => input,
Err(_) => {View on GitHub (pinned to bc7f02eddd)
Solutions
- Inspect the error string in the ACP response to identify the underlying variant and fix that condition.
- Verify the session is alive and the extension request targets a valid session id.
- If a new SideQuestionError variant was added, extend the match in handle_btw to map it to a specific ACP error code instead of InternalError.
Example fix
// before: everything unclassified becomes InternalError Err(e) => Err(acp::Error::new(acp::ErrorCode::InternalError.into(), e.to_string())), // after: handle known variants explicitly Err(SideQuestionError::Timeout) => Err(acp::Error::new(acp::ErrorCode::RequestTimeout.into(), "side question timed out")), Err(e) => Err(acp::Error::new(acp::ErrorCode::InternalError.into(), e.to_string())),
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure the session exists and accepts commands before sending SideQuestion
if agent.resident_handle(&sid).is_none() { return Err(create_session_first()); } Try / catch
match result {
Err(SideQuestionError::Sampling(e)) => Err(map_sampling_err_to_acp(e)),
Err(e) => {
tracing::error!(err = %e, "btw: unclassified side-question failure");
Err(acp::Error::new(acp::ErrorCode::InternalError.into(), e.to_string()))
}
Ok(answer) => Ok(answer),
} Prevention
- Map every new SideQuestionError variant to a specific ACP error code.
- Check session liveness before issuing SideQuestion commands.
- Include the error string in client-side logs for triage.
When it happens
Trigger: The SideQuestion command's oneshot responds with Err(e) where e is neither Ok(answer) nor SideQuestionError::Sampling — e.g. internal session state failures — while answering an 'x.ai/btw' extension request.
Common situations: Session shutting down mid-request; unexpected error variant after an extension update; agent internals failing to serialize the answer path.
Related errors
- session not found
- session not found
- session '{session_name}' is already running on port {} (use
- {} (session id: {session_id})
- ACP error: {err}
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/1d8bf2a532e5e160.
Report an issue: GitHub.