You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bidirectional context loop between JakartaEE/'PrimeFaces based web apps and AI agents
#26127
I'm not sure if this is the right place, if not, sorry, but let me try, since what I have is related to JakartaEE apps...
I think I have something useful and interesting for every JakartaEE JSF/PrimeFaces developer.
I built a system (I think it can be called a framework.) for developing JakartaEE web applications, on top of PrimeFaces, anf LangChain4j.
It is an advanced system, ready for developing applications that use artificial intelligence, and abstracts/simplifies the way of working with the langCjhain4J library. On the PrimeFaces side, its a SinglePage Application frm with dynamic tabs.
Among many advanced features, for this occasion, I would like to highlight the topic from the title: feeds the AI assistant with knowledge of what the user is doing in the application, and on the other hand, the AI streams the details of its work to the application.
Interesting project, and @TabScoped is a genuinely nice idea — a per-tab CDI scope is well-shaped and the cleanest part of this. It could probably go into PrimeFaces Extensions. The rest I'd push back on: a fair amount reinvents things the platform already gives you, and the AI part takes on more surface than it needs. A few suggestions that I think would make it much stronger and more "Jakarta-native", roughly in order of impact:
Lean on the platform for security. Right now there's a hand-rolled @AccessCheck / session-attribute authorization layer. Jakarta Security already solves this: SecurityContext.isCallerInRole(...) against the authenticated principal works identically on the JSF thread and the REST thread, with no fail-open corners to get wrong. Deleting the homegrown layer in favor of the container is a big net simplification. (While you're there: extend the security-constraint to cover /api/* — it's currently scoped to a single page.)
Go all-CDI. The business logic is currently a mix of POJOs, EJBs, and CDI beans, which means three different proxy/interceptor/authorization realities to reason about. @ApplicationScoped + @Transactional gives you one consistent model — container transactions without the EJB baggage — and removes the need for any proxy-unwrapping reflection.
Prefer opt-in over opt-out for tool exposure. This one's the sharpest: a tool channel is reachable by the model, whose inputs aren't fully trusted. Introspecting every public method means a prompt-injected or confused model can invoke anything on the beans you hand it — including state-mutating calls like processPayment / cancelOrder / deleteUser. Classic confused-deputy: it acts with your authority, off your script. And opt-out only grows the blast radius over time. An explicit @EasyTool allowlist (opt-in) exposes exactly what you annotated and nothing else, so adding a method stays safe by default.
Reserve AI for the genuinely irreducible bits. A lot of the demo flows — "show orders for X", "where is order ID 123", the checkout workflow — are vanilla lookups and plain algorithms and should be rewritten as such. Those are faster, auditable, testable, and safer as ordinary code. Save the LLM for the NL-based tasks that actually need it: summarization, translation, extraction, moderation, free-form chat, and RAG. For most of those a minimal no-tools client like OmniHai is plenty; you only need the heavier retrieval stack once a corpus outgrows in-memory similarity.
Hi and thanks for your usefull feedback.
Especially since this is the first time anyone has even given their opinion on this project, I had no idea what people thought about this tool.
I will cohsider each of your observation (I'll probably answer some of them here.), in an attempt to improve the tool.
Thanks again @BalusC
Hi @BalusC , this is the kind of review that actually moves a project. Let me go point by point: what I've already changed, what I'm changing, and the one or two places I'd push back with reasons:
1 — Security / fail-open
You caught a real one. The default in-memory interceptor had a genuine fail-open corner: a resource marked securedResource=true with no allowedRoles declared granted access with only a warning. That's exactly backwards.
I've flipped it to fail-closed — a secured resource with no matching rule now denies, loudly — with a regression test to keep it that way. It goes out in the next patch (3.0.1).
On the demo specifically, I agree: I'm moving it onto SecurityContext.isCallerInRole(...) against the authenticated principal and extending the security-constraint to cover /api/* instead of a single page.
Where I'd push back, gently: I'm keeping the pluggable interceptor in the library — not as a replacement for Jakarta Security, but as an SPI for it. The base is abstract; getUserRoles() is meant to be overridden onto isCallerInRole, and the DB strategy exists for apps whose authorization is dynamic and admin-managed at runtime (per-resource rules editable without a redeploy), where static container roles aren't the whole story. What changes is the default and the recommendation: Jakarta Security becomes the documented path.
2 — Go all-CDI
Agreed for the demo. Modeling business logic as a mix of POJOs, EJBs, and CDI beans sends a muddled message, and @ApplicationScoped + @transactional is the cleaner one-model story. I'll straighten the demo out that way.
One clarification on the "proxy-unwrapping reflection": it isn't there to prop up the mix — it's a deliberate capability so that people who do have EJBs can hand them to the AI as tools with container semantics (transactions, security, interceptors) intact, since calls still go through the container proxy. I'd keep that in the library. So: the demo stops modeling the mix, the library keeps EJBs as a supported option.
3 — Opt-in over opt-out for tools
This was the sharpest point, and you were right — so I shipped it. As of 3.0.0, tools are opt-in: only methods annotated with @easytool are exposed to the model. Everything else — cancelOrder, processPayment, deleteUser — is invisible and uncallable, so adding a method to a service is safe by default. There's an intentionally ugly escape hatch (withAllPublicMethodsAsTools(...)) for throwaway prototypes, named so the risk is obvious at the call site.
It applies to EJBs too — there's a regression test proving an unannotated deleteInvoice on a @stateless bean stays uncallable. It was a breaking change to a documented default, so it got a clean major rather than a silent flip.
4 — Reserve AI for the genuinely irreducible bits
Half agree. A plain "show orders for X" is a lookup and should be plain code — some of the demo's flows are illustrative wiring rather than production patterns, and I'll label them as such so they're not read as recommendations.
Where I'd hold: the core isn't the lookup, it's the deixis. "Cancel this", "what am I looking at" — resolving "this" from a stream of ambient in-app activity is exactly the NL routing that plain code doesn't give you. That's the irreducible part I'm actually building around, not the CRUD.
And on keeping the client minimal — fair. Not every use needs the heavy retrieval stack; there's already a no-tools, no-RAG chat path, and I'm planning to mark the RAG/Milvius dependencies so they don't bloat a WAR that only wants chat or tools.
On @TabScoped
Thank you — I think thats the cleanests part too. A per-tab CDI scope is genuinely useful beyond this project, and I'm seriously looking at proposing it to PrimeFaces Extensions., if you have a sense of whether it'd be welcome there, or the best way in, I'd value the pointer.
P.S. — Stepping back from the specific points: you clearly have reach in the Jakarta EE world, and I'd genuinely value your take on the part I know least about. I've spent the efort on building and documenting this entire tabgorge-ai library; but getting it in front of the developers who'd actually use it is the harder problem for me. Any pointers — where this kind of library gets noticed, what makes a team give a new one a real look, mstakes to avoid — would mean a lot for me.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
I'm not sure if this is the right place, if not, sorry, but let me try, since what I have is related to JakartaEE apps...
I think I have something useful and interesting for every JakartaEE JSF/PrimeFaces developer.
I built a system (I think it can be called a framework.) for developing JakartaEE web applications, on top of PrimeFaces, anf LangChain4j.
It is an advanced system, ready for developing applications that use artificial intelligence, and abstracts/simplifies the way of working with the langCjhain4J library. On the PrimeFaces side, its a SinglePage Application frm with dynamic tabs.
Among many advanced features, for this occasion, I would like to highlight the topic from the title:
feeds the AI assistant with knowledge of what the user is doing in the application, and on the other hand, the AI streams the details of its work to the application.
Thats why I mention "bidirectional context loop between web apps and AI agents "
The AI assistant knows what user doing in the app
AI streams his work details in the app
If you want to explore it:
GitHub: https://github.com/tabforgeai/tabforge-ai
Full example: https://github.com/tabforgeai/tabforge-ai-demo
I would love to hear your opinion on this tool....
-best regards,...
All reactions