Skip to content

feat: self-reported prompts, client and used skills - #205

Merged
andyMrtnzP merged 4 commits into
mainfrom
feat/skill-bucket-p2
Jul 27, 2026
Merged

feat: self-reported prompts, client and used skills#205
andyMrtnzP merged 4 commits into
mainfrom
feat/skill-bucket-p2

Conversation

@andyMrtnzP

@andyMrtnzP andyMrtnzP commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added support for preserving and forwarding session source information across WebSocket connections.
    • Prompts are now sent with the first applicable browser command.
    • Site recipe runs now reliably report their final outcome (recipe domain/task and success status).
  • Bug Fixes

    • Improved session reconnection to keep connection metadata consistent.
    • Added safer handling for outcome reporting and batches with no user-facing results, avoiding incorrect fallbacks/errors.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The agent now propagates MCP source attribution through WebSocket session creation and reconnection. Command execution forwards a prompt once, reports site-recipe outcomes, and safely handles batches without user-facing results.

Changes

Agent session and reporting changes

Layer / File(s) Summary
Session source propagation
src/@types/types.d.ts, src/lib/agent-client.ts, src/tools/agent.ts
ActiveSession stores an optional source, which browserless_agent passes through session creation and connect() into the x-browserless-mcp-source WebSocket header, including reconnects.
Prompt and skill outcome reporting
src/skills/system-prompt.ts, src/tools/agent.ts
Site-recipe runs are instructed to finish with reportSkillOutcome; commands inject _prompt once per session, suppress reporting errors, and return a completion message when no reportable results exist.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant browserless_agent
  participant getOrCreateSession
  participant connect
  participant BrowserWebSocket
  browserless_agent->>getOrCreateSession: open session with mcpSource.source
  getOrCreateSession->>connect: pass source
  connect->>BrowserWebSocket: upgrade with x-browserless-mcp-source
  BrowserWebSocket-->>connect: establish browser session
  browserless_agent->>getOrCreateSession: send commands
  getOrCreateSession-->>browserless_agent: inject _prompt once and process reportSkillOutcome
Loading

Possibly related PRs

Suggested reviewers: artiom

Poem

I’m a rabbit with headers tucked neat,
Sending source tags where sessions meet.
One prompt hops into commands just right,
Outcome reports make the run complete.
Sproing—clean trails from start to byte!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning No PR description was provided, so none of the required template sections are present. Add the Summary, Related issues, Changes, Test plan, and Checklist sections from the template.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and covers the main theme: self-reported prompts and client/skill handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/skill-bucket-p2

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/tools/agent.ts (1)

683-683: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Track prompt delivery on ActiveSession, not per tool invocation.

promptSent is recreated inside runCommands, while getOrCreateSession reuses persistent sessions. Subsequent calls can therefore send _prompt again, and concurrent calls can both pass the guard. Store the delivery state on ActiveSession and claim it synchronously before sending.

Also applies to: 712-717

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tools/agent.ts` at line 683, Move prompt delivery tracking from the
per-invocation promptSent variable in runCommands onto the persistent
ActiveSession object reused by getOrCreateSession. In the _prompt delivery path
around lines 712-717, synchronously check and claim the session-level state
before sending so subsequent and concurrent calls send the prompt only once.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/agent-client.ts`:
- Around line 744-745: Update the ActiveSession state and its initialization to
retain the original compliant value, then replace the hard-coded false in the
reconnect flow with session.compliant. Ensure reconnects use the same compliance
setting as initial session creation.
- Line 630: Update getOrCreateSession so session cache and pending-session
lookups account for the source value, preventing calls with different
mcpSource.source values from reusing the same browser; alternatively, explicitly
reject source changes before reuse. Ensure the selected session always sends the
matching x-browserless-mcp-source header.

In `@src/skills/system-prompt.ts`:
- Line 15: Update the executor handling for reportSkillOutcome so it is treated
as a terminal internal command: exclude it from user-facing result selection and
automatic getDownloads post-processing, ensure it is sent exactly once only when
a recipe was loaded, and define cleanup ordering so it is dispatched as the
final WebSocket command without being blocked by close. Use the existing
executor command-processing and result-selection symbols near the system prompt
integration.

---

Nitpick comments:
In `@src/tools/agent.ts`:
- Line 683: Move prompt delivery tracking from the per-invocation promptSent
variable in runCommands onto the persistent ActiveSession object reused by
getOrCreateSession. In the _prompt delivery path around lines 712-717,
synchronously check and claim the session-level state before sending so
subsequent and concurrent calls send the prompt only once.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0d98d235-ed2e-456d-b1e6-d3bb22fb6392

📥 Commits

Reviewing files that changed from the base of the PR and between 73af19e and 8ee279a.

📒 Files selected for processing (4)
  • src/@types/types.d.ts
  • src/lib/agent-client.ts
  • src/skills/system-prompt.ts
  • src/tools/agent.ts

Comment thread src/lib/agent-client.ts
Comment thread src/lib/agent-client.ts Outdated
Comment thread src/skills/system-prompt.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/tools/agent.ts (1)

683-683: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Scope _prompt to the session, not the batch. getOrCreateSession() reuses an existing ActiveSession, so promptSent resets on every runCommands() call and the same session can receive _prompt again on later tool calls. Store the flag on ActiveSession or change the comment to “once per batch.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tools/agent.ts` at line 683, Persist the prompt-sent state on
ActiveSession rather than declaring promptSent inside runCommands, so
getOrCreateSession() reuses it across calls and each session receives _prompt
only once. Update the relevant ActiveSession definition and _prompt dispatch
logic while preserving per-session behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/tools/agent.ts`:
- Around line 698-705: Update the command/result tracking around the
reportSkillOutcome branch and the later lastCmd derivation so skipped
reportSkillOutcome commands cannot shift the association between recorded
results and originating commands. Preserve the existing send-and-ignore
behavior, while keeping each recorded result tied to its source command or
deriving lastCmd from that association so batches such as goto,
reportSkillOutcome, screenshot use screenshot for formatting and skill
detection.

---

Outside diff comments:
In `@src/tools/agent.ts`:
- Line 683: Persist the prompt-sent state on ActiveSession rather than declaring
promptSent inside runCommands, so getOrCreateSession() reuses it across calls
and each session receives _prompt only once. Update the relevant ActiveSession
definition and _prompt dispatch logic while preserving per-session behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8f42c280-5343-4c84-a9ce-18001a9e560b

📥 Commits

Reviewing files that changed from the base of the PR and between 8ee279a and a2b9985.

📒 Files selected for processing (4)
  • src/@types/types.d.ts
  • src/lib/agent-client.ts
  • src/skills/system-prompt.ts
  • src/tools/agent.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/skills/system-prompt.ts
  • src/@types/types.d.ts
  • src/lib/agent-client.ts

Comment thread src/tools/agent.ts
@andyMrtnzP
andyMrtnzP merged commit ee4f11a into main Jul 27, 2026
6 checks passed
@andyMrtnzP
andyMrtnzP deleted the feat/skill-bucket-p2 branch July 27, 2026 23:16
andyMrtnzP pushed a commit that referenced this pull request Jul 27, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.16.0](v1.15.0...v1.16.0)
(2026-07-27)


### Features

* self-reported prompts, client and used skills
([#205](#205))
([ee4f11a](ee4f11a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: browserless-actions-bot[bot] <186328842+browserless-actions-bot[bot]@users.noreply.github.com>
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.

2 participants