Questions: agents write their findings before asking; an open question isn't 'Stopped'
An agent put its whole analysis in thinking (not shown) and asked a question straight away, so the operator saw only the question form under a 'Stopped after 2 tools' row. The Pipelines tool instructions now tell agents to write what they found before asking, and an activity row with an open question reads '... · waiting for your answer'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -103,18 +103,38 @@ class ChatTurnActivityData {
|
||||
final noun = commands
|
||||
? (calls.length == 1 ? 'command' : 'commands')
|
||||
: (calls.length == 1 ? 'tool' : 'tools');
|
||||
// A question still open is the agent waiting on the operator, not a
|
||||
// stopped turn: say so instead of "Stopped after".
|
||||
final asking = calls.any(
|
||||
(p) => chatToolIsQuestion(p) && !chatToolSettled(p),
|
||||
);
|
||||
final summary =
|
||||
'${unfinished
|
||||
'${unfinished && !asking
|
||||
? 'Stopped after'
|
||||
: commands
|
||||
? 'Ran'
|
||||
: 'Used'} ${calls.length} $noun';
|
||||
return failed == 0 ? summary : '$summary · $failed failed';
|
||||
final status = asking ? '$summary · waiting for your answer' : summary;
|
||||
return failed == 0 ? status : '$status · $failed failed';
|
||||
}
|
||||
|
||||
bool get failed => tools.any(chatToolFailed);
|
||||
}
|
||||
|
||||
/// Whether [tool] asks the operator a question (Claude Code's
|
||||
/// AskUserQuestion, or a harness tool named like it).
|
||||
bool chatToolIsQuestion(JsonMap tool) {
|
||||
final name = chatToolLabel(tool).toLowerCase().replaceAll('_', '');
|
||||
return name == 'askuserquestion' || name == 'question';
|
||||
}
|
||||
|
||||
/// Whether [tool] has a final state (completed, failed or answered).
|
||||
bool chatToolSettled(JsonMap tool) {
|
||||
final state = tool['state'];
|
||||
final status = state is Map ? '${state['status']}' : '$state';
|
||||
return const ['completed', 'error', 'failed', 'done'].contains(status);
|
||||
}
|
||||
|
||||
/// Whether [tool] is a shell command (`Ran N commands`), not another tool.
|
||||
bool chatToolIsCommand(JsonMap tool) => const [
|
||||
'bash',
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_turn_activity.dart';
|
||||
|
||||
Map<String, dynamic> _tool(String name, String status) => {
|
||||
'type': 'tool',
|
||||
'id': name,
|
||||
'name': name,
|
||||
'state': {'status': status, 'title': ''},
|
||||
};
|
||||
|
||||
void main() {
|
||||
test('an open question reads as waiting for the operator, not stopped', () {
|
||||
final activity = ChatTurnActivityData([
|
||||
_tool('Bash', 'completed'),
|
||||
_tool('AskUserQuestion', 'pending'),
|
||||
], streaming: false);
|
||||
expect(activity.label, 'Used 2 tools · waiting for your answer');
|
||||
});
|
||||
|
||||
test('an answered question is an ordinary used tool', () {
|
||||
final activity = ChatTurnActivityData([
|
||||
_tool('Bash', 'completed'),
|
||||
_tool('AskUserQuestion', 'completed'),
|
||||
], streaming: false);
|
||||
expect(activity.label, 'Used 2 tools');
|
||||
});
|
||||
|
||||
test('another interrupted tool still reads as stopped', () {
|
||||
final activity = ChatTurnActivityData([
|
||||
_tool('Bash', 'completed'),
|
||||
_tool('Read', 'interrupted'),
|
||||
], streaming: false);
|
||||
expect(activity.label, 'Stopped after 2 tools');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user