Skip to content

[python] Backfill remote test coverage ahead of local execution path removal - #881

Merged
wenjin272 merged 5 commits into
apache:mainfrom
weiqingy:829-pr1-backfill-remote-tests
Jul 10, 2026
Merged

wenjin272 merged 5 commits into
apache:mainfrom
weiqingy:829-pr1-backfill-remote-tests

Conversation

@weiqingy

@weiqingy weiqingy commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Linked issue: #829

Purpose of change

This is the first of two PRs retiring the Python in-process local execution path (local_runner / local_execution_environment) in favor of validating agent logic on Flink's MiniCluster, per #829.

This PR is purely additive. Several behaviors are currently exercised only through the local path (via its from_list / to_list / get_tool_request_events test API); before the local path can be removed, that coverage has to exist on the remote (real-Flink) path. This PR backfills it, so the follow-up deletion PR removes the local path without losing any coverage.

New remote (MiniCluster) tests added:

  • Synchronous durable_execute exception propagation and keyword-argument calls — the existing remote durable-execute tests only covered the async-exception and positional-argument paths.
  • Built-in chat_model_action + tool_call_action content and tool binding, driven by a deterministic mock chat model (the mock stubs only LLM inference, so the built-in actions remain the code under test).
  • get_resource(CHAT_MODEL) inside an action, including custom ResourceDescriptor field pass-through.
  • MCP tool invocation and prompt retrieval, invoked directly via get_resource(...).call(...) with no LLM — mirroring the existing Java MCPCrossLanguageAgent pattern and gated only on the self-started MCP server. This is the first remote MCP coverage in the repo.
  • The apply(<unknown-name>) → ValueError guard on the remote builder (unit test; the guard fires before a cluster starts).
  • Short-term-memory workflow semantics: same-key visit_count accumulation across records, and auto-generated key for a record with no key.
  • Chat model coverage for the non-Ollama providers (Tongyi / OpenAI / AzureOpenAI) on the remote path, preserving the original per-provider credential gating.

Tests

This PR is entirely tests. Verified on a Flink MiniCluster: one end-to-end session runs 11 passed, 3 skipped (the skips are the credential-gated provider cases). The deterministic tests (durable-execute, built-in action, MCP, workflow memory) run without any external service; the MCP test self-starts the MCP server. The apply-guard unit test runs without a cluster.

API

No public API changes. Test-only.

Documentation

  • doc-needed
  • doc-not-needed
  • doc-included

weiqingy added 3 commits July 6, 2026 19:06
…kwargs

Backfill remote (MiniCluster) coverage for two durable_execute behaviors
previously exercised only by the in-process local execution path: propagation
of exceptions raised through synchronous durable_execute, and calling
durable_execute with keyword arguments. Existing remote tests covered only the
async-exception and positional-argument paths.

Mirrors the established execute_test.py pattern (FileSource in, StreamingFileSink
out, check_result assertion) with matching ground-truth files.
…del get_resource

Backfill remote (MiniCluster) coverage, using a deterministic mock chat model,
for behavior previously exercised only by the in-process local execution path:
the built-in chat_model_action + tool_call_action content flow with correct tool
binding, and get_resource(CHAT_MODEL) inside an action with custom
ResourceDescriptor field pass-through.

The mock stubs only LLM inference, so the framework's built-in actions remain the
code under test. Follows the execute_test.py agent/test split and resource
convention.
Backfill remote (MiniCluster) MCP coverage — none existed. The test invokes the
MCP tool and fetches the MCP prompt directly via get_resource, with no LLM,
mirroring the Java MCPCrossLanguageAgent pattern. It self-starts the existing MCP
server scripts and gates only on server readiness (no Ollama), asserting the
server-computed sum and prompt content for both with-prompts and without-prompts
server modes.
@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs fixVersion/0.4.0 priority/major Default priority of the PR or issue. labels Jul 7, 2026
…non-Ollama chat providers

Backfill the remaining behaviors covered only by the in-process local execution
path: the apply(unknown-name) ValueError guard on the remote builder (unit test,
no cluster); short-term-memory workflow semantics (same-key visit_count
accumulation and auto-generated key for a keyless record) on a real MiniCluster;
and chat model coverage for the non-Ollama providers (Tongyi/OpenAI/AzureOpenAI)
on the remote path, keeping the original per-provider credential gating.

@wenjin272 wenjin272 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.

Thanks for this work @weiqingy. I left one comment.

return int(result[0])


class MCPRemoteWithPromptsAgent(Agent):

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.

It seems this Agent is intended to replace MyMCPAgent in e2e_tests_mcp/mcp_test.py. However, unlike its predecessor, it does not bind MCP prompts and tools to the ChatModel, which I consider a regression in test coverage. Could we continue using MyMCPAgent instead, limiting changes to only the submission and validation logic within the test_mcp function?

@weiqingy weiqingy Jul 8, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the review @wenjin272 . Good catch. Fixed in e2272ee: MyMCPAgent is kept as-is and only test_mcp's submission/validation move to the MiniCluster path; the direct-invocation agent/test are removed. Could you take another look? Let me know if you have any concerns.

Preserves the MCP->ChatModel binding coverage (the add tool and ask_sum
prompt bound into a chat_model_setup) that the direct-invocation agent
lacked. Only test_mcp's submission and validation move from the local
from_list/to_list path to a FileSource + StreamingFileSink round-trip on a
real StreamExecutionEnvironment; MyMCPAgent itself is unchanged. The
direct-invocation agent/test and its ground-truth fixtures are removed.

@wenjin272 wenjin272 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.

LGTM

@wenjin272
wenjin272 merged commit 2f56f97 into apache:main Jul 10, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs fixVersion/0.4.0 priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants