Files
buzz/mobile/lib/features/agents/agent_identity_sections.dart
Tom Brow 9d1b684455 fix(mobile): show remote agent instructions from the registry (#8908)
After creating a remote (Builderbot) agent with instructions on mobile,
its profile said "Instructions aren't available on mobile for this
agent."

Two causes:
- Mobile called `list-agents` without `include_instructions: true`, so
registry rows had no `agent_instructions`. Desktop already sends this
flag.
- The profile read instructions only from published desktop agent
config, which remote agents don't have.

Now mobile requests instructions in `list-agents` (both the listing and
the post-create readback). For an agent in the active community owner's
registry listing, the profile shows the row's `agent_instructions`. Like
desktop, a missing field means "No instructions set." Desktop agents
keep the published-config path.

Because listings now carry instructions (up to 20,000 characters each),
`list-agents` gets a 4 MB response bound instead of 64 KB. The
delete-retry journal, which lives in plain preferences, drops
instructions before it's written.

### Before / after

iPhone SE, remote-agent-pilot community: profile of an agent just
created on mobile with the instructions "Reply in one short sentence."

| Before (main) | After (this PR) |
| --- | --- |
| <img
src="https://raw.githubusercontent.com/block/buzz/5d7333ea429e6c8c8aae93846d23c3a2bb9bda25/pr-8908--before-instructions.png"
width="300"> | <img
src="https://raw.githubusercontent.com/block/buzz/5d7333ea429e6c8c8aae93846d23c3a2bb9bda25/pr-8908--after-instructions.png"
width="300"> |

### Validation

- Extended `agents_sheet_test.dart`: the remote-agent case asserts the
`include_instructions` flag and that the profile shows the registry
text. It fails without the fix.
- New/extended tests for the larger `list-agents` bound and the retry
journal; each fails with its fix reverted.
- `just mobile-check` and the mobile test suite pass.
- iPhone SE (release build, remote-agent-pilot community): created an
agent with instructions on mobile, then opened its profile, which showed
them. Deleted the test agent afterward.

buzz-review-completed (manual testing waived by Tom)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 18:53:02 -08:00

74 lines
2.4 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../shared/community/community_provider.dart';
import '../../shared/agents/remote_agents.dart';
import '../../shared/theme/theme.dart';
import '../../shared/widgets/app_list_card.dart';
import 'agent_instructions.dart';
/// The agent's instructions and management information in shared Settings cards.
class AgentIdentitySections extends HookConsumerWidget {
const AgentIdentitySections({
required this.pubkey,
required this.controller,
super.key,
});
final String pubkey;
final RemoteAgentController controller;
@override
Widget build(BuildContext context, WidgetRef ref) {
useListenable(controller);
final remote = controller.agents.any(
(agent) => agent['agent_pubkey'] == pubkey,
);
// Remote instructions come from the registry row, listed for the active
// community's owner only (as the agents page decides).
final owner = ref.watch(activeCommunityProvider).asData?.value?.pubkey;
final row = owner != null && controller.owner == owner
? controller.agents
.where((agent) => agent['agent_pubkey'] == pubkey)
.firstOrNull
: null;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
AppListCard(
label: 'Instructions',
horizontalPadding: 0,
children: [
Padding(
padding: const EdgeInsets.all(Grid.xs),
child: SizedBox(
width: double.infinity,
child: AgentInstructions(pubkey: pubkey, registryRow: row),
),
),
],
),
AppListCard(
label: 'Management',
horizontalPadding: 0,
children: [
Padding(
padding: const EdgeInsets.all(Grid.xs),
child: SizedBox(
width: double.infinity,
child: Text(
remote
? 'This agent runs on Builderbot. Your desktop doesn’t need to be online for it to work.'
: 'This agent is managed on your desktop. Keep Buzz open and your desktop online for it to work.',
style: context.textTheme.bodyMedium,
),
),
),
],
),
],
);
}
}