Skip to content

Commit f6510d5

Browse files
committed
Merge branch 'mcp_server' of github.com:ServiceNow/BrowserGym into mcp_server
2 parents df54d80 + f1334e8 commit f6510d5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

browsergym/core/src/browsergym/utils/mcp_server.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]:
126126
mcp = FastMCP("BrowserGym", lifespan=app_lifespan)
127127

128128

129+
def format_func_call(func: Callable, args, kwargs) -> str:
130+
args_str = ", ".join(repr(arg) for arg in args)
131+
kwargs_str = ", ".join(f"{k}={repr(v)}" for k, v in kwargs.items())
132+
all_args_str = ", ".join(filter(None, [args_str, kwargs_str]))
133+
return f"{func.__name__}({all_args_str})"
134+
135+
129136
def fn_wrapper(func: Callable, validate: bool = True):
130137
async def decorator(*args, **kwargs):
131138
"""
@@ -146,7 +153,7 @@ async def decorator(*args, **kwargs):
146153

147154
fn = getattr(fn_context, func.__name__)
148155

149-
gym.last_action = fn.__name__
156+
gym.last_action = format_func_call(fn, args, kwargs)
150157
info, send_message_to_user, report_infeasible_instructions = await asyncio.to_thread(
151158
gym.pre_step
152159
)

0 commit comments

Comments
 (0)